Help with Lisp

Discussion in 'AutoCAD' started by ragetoca, Mar 28, 2005.

  1. ragetoca

    ragetoca Guest

    Ok,
    I have this lisp routine that creates a leader with an arrow (pline).
    I am doing some contract work for an architect and he has an arrow that he likes to use. I would like to incorporate this arrow block into my lisp routine, but I don't have a clue how to do it!!
    Can I get some help?
    This guy notes and dimensions in Paper space so I dont have to worry about dimscale.

    Here is the routine that I have:

    (defun c:arrow (/ sp ang arrang leng ep)
    (setq sp (getpoint "\narrow start point:")
    angp (getangle sp "\narrow angle:")
    len (* 0.09 (getvar"dimscale"))
    ep (polar sp angp len)
    ew (* 0.03 (getvar"dimscale"))
    )
    (command "pline" sp "w" "0.0" ew
    ep "w" "0.0" "0.0" "arc" pause "")
    (princ))
     
    ragetoca, Mar 28, 2005
    #1
  2. ragetoca

    Walt Engle Guest

    I have a lsp routine that begins with a std arrow (if you're interested). However, the problem I see with a block is that what you want to do is insert the arrowhead and have a leader come from it -
    at any angle? Here you have a problem with the angle part.

    Can you post the block?
     
    Walt Engle, Mar 28, 2005
    #2
  3. ragetoca

    ECCAD Guest

    This seems to work for the __Arrow-Hand block.
    ;;INS-ARO.LSP
    ;;
    ;; Degrees to Radians, Radians to Degrees
    (defun dtr (d) (* pi (/ d 180.0)))
    (defun rtd (r) (* 180.0 (/ r pi)))

    ;;
    (defun C:INS-ARO ()
    (setq pt1 (getpoint "\nPick Beginning Leader Point:"))
    (setvar "orthomode" 0)
    (setq pt2 (getpoint pt1 "\nPick 2nd Leader Point:"))
    (setvar "orthomode" 1)
    (setq pt3 (getpoint pt2 "\nPick 3rd Leader Point:"))
    (setq ang (angle pt1 pt2))
    (command "-insert" "__Arrow-Hand" pt1 (getvar "dimscale") "" (rtd ang))
    (command "_pline" pt1 "w" "0.0" "0.0" pt2 pt3 "")
    (princ)
    ); function

    Bob
     
    ECCAD, Mar 28, 2005
    #3
  4. ragetoca

    ragetoca Guest

    it works but I was expecting an arc with a leader not a straight one
     
    ragetoca, Mar 29, 2005
    #4
  5. Use the Spline variety of leader. Some people say they like a real arc
    better, but to my mind, the difference is insignificant compared to the many
    advantages of using a real leader (such as that the arrowhead turns if you
    change the leader's path, all of them can be globally assigned a different
    arrowhead or size of arrowhead at once if you need to, etc., etc.). You can
    build the Spline choice (F for "format" after the second leader point, then
    S for "spline") into a menu item or a routine, much more easily than you can
    build an arrowhead as a polyline segment that will then have all those
    shortcomings. You can also build in bypassing of the annotation part of the
    leader command, if you prefer.
     
    Kent Cooper, AIA, Mar 29, 2005
    #5
  6. ragetoca

    ragetoca Guest

    Well,
    Like I said, I am doing contract work with an architect who is very PICKY about how the drawings look. So he wants an ARROW with his own ARROWHEAD, so a spline won't work, believe me, he will note the difference.
    I have not found anything that works right.
    Is there anyway to make the block part of the arc??

    JR
     
    ragetoca, Mar 29, 2005
    #6
  7. ragetoca

    ECCAD Guest

    Give this one a whirl.


    ;;ARC-ARO.LSP
    ;;
    ;; Degrees to Radians, Radians to Degrees
    (defun dtr (d) (* pi (/ d 180.0)))
    (defun rtd (r) (* 180.0 (/ r pi)))

    ;;
    (defun C:ARO-ARC ()
    (setq pt1 (getpoint "\nPick Beginning Leader Point:"))
    (setvar "orthomode" 0)
    (setq pt2 (getpoint pt1 "\nPick Point along the ARC:"))
    (setq ang (angle pt1 pt2))
    (command "-insert" "__Arrow-Hand" pt1 (getvar "dimscale") "" (rtd ang))
    (command "pline" pt1 "w" "0.0" (* 0.03 (getvar "dimscale"))
    pt2 "w" "0.0" "0.0" "arc" pause "")
    (princ)
    ); function

    Bob
     
    ECCAD, Mar 29, 2005
    #7
  8. ragetoca

    CAB2k Guest

    Give this a try.
    Creates the block if it doesn't exist & places the arc & block
    on layer A-Dims, color 9
    Note the block name is different than yours as the block is pointing
    in the opposite direction as yours.

    Code:
    ;;;   ArcArw2.lsp    (Arc Leader)
    ;;;   Uses the current layer & "__Arrow-Hand-" Arrow head
    ;;;   Uses Layer A-DIMS
    ;;;
    ;;; ARGUMENTS
    ;;; none
    ;;;
    ;;; USAGE
    ;;; ArcArw2
    ;;;
    ;;; PLATFORMS
    ;;; 2000+ , tested in 2000
    ;;;
    ;;; AUTHOR
    ;;; Copyright© 2005 Charles Alan Butler
    ;;; 
    ;;;
    ;;; VERSION
    ;;; 1.0 Mar 29, 2005
    ;;
    ;; YOU MAY USE THIS CODE ONLY FOR *NON-COMMERCIAL*
    ;; PURPOSES AND ONLY IF YOU RETAIN
    ;; THIS HEADER COMPLETE AND UNALTERED
    ;; you must contact me if you want to use it commercially
    ;;
    ;;;======  Main Lisp Routine  =======
    (defun c:ArcArw2 (/ blkName blksize usercmd useros userangdir ptpick
    lastpt arwsize ang dist ENPT LEN P1 STPT VOBJ clayer
    lyr clr
    )
    (vl-load-com)
    (setq blkName "__Arrow-Hand-"
    lyr "A-DIMS"
    clr "9")
    
    ;; error function & Routine Exit
    (defun *error* (msg)
    (if
    (not
    (member
    msg
    '("console break" "Function cancelled" "quit / exit abort" "")
    )
    )
    (princ (strcat "\nError: " msg))
    ) ; if
    (setvar "osmode" useros)
    (setvar "CMDECHO" usercmd)
    (setvar "angdir" userangdir)
    (setvar "clayer" clayer)
    (princ)
    ) ;end error function
    
    
    (defun makemyblk (blkname) ; make arrow head
    (entmake
    (list '(0 . "BLOCK") ; required
    '(100 . "AcDbEntity") ; recommended
    '(100 . "AcDbBlockBegin") ; recommended
    (cons 2  blkName) ; required
    '(8 . "0") ; recommended
    '(70 . 0) ; required
    '(10 0.0 0.0 0.0) ; required
    )
    )
    (entmake '((0 . "LINE") (8 . "0") (62 . 2) (10 0.0 0.0 0.0)
    (11 -0.0424347 0.00726653 0.0)))
    (entmake '((0 . "LINE") (8 . "0")
    (10 -0.0848694 0.0145331 0.0) (11 -0.0971044 -0.0110695 0.0)))
    (entmake '((0 . "LINE") (8 . "0") (62 . 13)
    (10 -0.0971044 -0.0110695 0.0) (11 -0.103086 -0.0235868 0.0))
    )
    (entmake '((0 . "LINE") (8 . "0")(62 . 2) (10 0.0 0.0 0.0)
    (11 -0.0429225 -0.00334164 0.0)))
    (entmake '((0 . "LINE") (8 . "0")
    (10 -0.0429225 -0.00334164 0.0) (11 -0.111367 -0.00867022 0.0)))
    (entmake '((0 . "LINE") (8 . "0") (10 0.0 0.0 0.0) (11 -0.0918145 0.0 0.0)))
    (entmake '((0 . "LINE") (8 . "0")
    (10 -0.0424347 0.00726653 0.0) (11 -0.0848694 0.0145331 0.0)))
    
    (entmake (list '(0 . "ENDBLK") ; required
    '(100 . "AcDbBlockEnd") ; recommended
    '(8 . "0") ; recommended
    )
    )
    ;;==============================================
    ) ;defun
    
    
    ;;;=============================================================
    ;;;=============================================================
    ;;;                  Routine Starts Here
    ;;;=============================================================
    ;;;=============================================================
    (princ "\n       Arc Leader Custom Head - Version 1.0")
    
    ;;; -------  Some Housekeeping   ------------------
    (setq usercmd (getvar "CMDECHO"))
    (setvar "CMDECHO" 0)
    (setq useros (getvar "osmode"))
    (setq userangdir (getvar "angdir"))
    (setvar "angdir" 0)
    (setq clayer (getvar "clayer"))
    
    ;;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    ;;  Determine the arrow head size
    ;;(setq arwsize (* (getvar "dimasz") (getvar "dimscale")))
    (setq arwsize 1.09375) ; 3/32 block size
    (setq blksize (1- arwsize))
    ;;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    
    ;;  loop until user enters point
    (while
    (not
    (setq ptpick
    (getpoint "\n***  Draw arc, Start at arrow head.  ***")))
    (princ "\nPlease try again..."))
    (if (tblsearch "LAYER" lyr)
    (command "._Layer" "_Thaw" lyr "_On" lyr "_UnLock" lyr "_Set" lyr "")
    (command "._Layer" "_Make" lyr "_Color" (if (= Clr "") "_White" Clr) lyr "")
    )
    
    (command "._arc" ptpick pause pause)
    (if (= "ARC" (cdr (assoc 0 (entget (entlast)))))
    (progn ; arc created
    
    (setq vobj (vlax-ename->vla-object (entlast)))
    (setq stpt (vlax-curve-getstartpoint vobj))
    (setq enpt (vlax-curve-getendpoint vobj))
    (setq len (vlax-curve-getdistatparam
    vobj
    (vlax-curve-getendparam vobj)
    )
    )
    (if (< (distance stpt ptpick) (distance enpt ptpick))
    (setq dist blksize)
    (setq dist (- len blksize))
    )
    
    (if (not (tblsearch "block" blkName))
    (makemyblk blkname)
    )
    
    (setq p1 (vlax-curve-getpointatdist vobj dist))
    (setq ang (* 180.0 (/ (angle p1 ptpick) pi)))
    (setvar "osmode" 0)
    ;(command "point" ptpick)
    ;(command  "point" p1)
    (command "_.insert" blkName "S" (abs arwsize) ptpick ang)
    )
    ) ; endif
    
    (*error* "")
    (princ)
    ) ;  end defun
    (prompt "\n>>>-->  Arc Leader Loaded, Type  ArcArw2 to run")
    (princ)
    
    ;;;==========  End of Routine  ============
    
     
    CAB2k, Mar 30, 2005
    #8
  9. ragetoca

    Shane-W Guest

    I may have missed something but a spline leader with a custom arrowhead block seems like all you need.

    just have his arrow head as a block and select user arrow for the arrow type. refer to your autocad help file for "creating arrowheads"
     
    Shane-W, Mar 30, 2005
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.