Jump to content

Recommended Posts

Posted

I have been trying to learn LISP and use some functions to make things work better.

 

I have an Arc Leader lisp that I have modified to use my company's arrowhead, changed the command to scale to dimscale but I am missing something about the arrowhead placement and the allowable size of the arc which the arrowhead can be placed on. I have attached the lisp command that I have modified so far, the arrowhead I want to use, which is the correct size and scales great. I have also added a few pictures, One of my command line when the arc leader is too small to attach the arrowhead. And the corresponding arc in the model. Also a picture of multiple arcs created showing that the arrowhead is not rotating when placed to be aligned with the arc.

 

Any help is greatly appreciated, please also tell me where I went wrong in the modifications as I am trying to learn LISP so I can improve my skills and also hopefully helps others in the future.

 

Thank you,

Jim

Arc Leader-AW.lsp

AW-JGA.dwg

Different Length Arcs.jpg

Command Line.png

Arc leader in Drawing.png

Posted

Lee Mac's Lisp routine is great but it does not let you specify the arrow head only the length and width. I need the arrow head to be the same block that my company currently uses.

Posted

Please try the following:

[color=GREEN];; Arrow Leader  -  Lee Mac[/color]

([color=BLUE]defun[/color] c:aa ( [color=BLUE]/[/color] ahb blk dis ent len ocs pt1 pt2 scl )
   ([color=BLUE]setq[/color] ahb [color=MAROON]"AW-JGA"[/color]                    [color=GREEN];; Arrowhead block[/color]
         scl ([color=BLUE]getvar[/color] 'dimscale)          [color=GREEN];; Arrowhead scale[/color]
         len ([color=BLUE]*[/color] scl 0.07812501562757113) [color=GREEN];; Arrowhead length[/color]
   )
   ([color=BLUE]cond[/color]
       (   ([color=BLUE]not[/color] ([color=BLUE]setq[/color] blk (LM:importblock ahb)))
           ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\n\""[/color] ahb [color=MAROON]"\" block/drawing not found."[/color]))
       )
       (   ([color=BLUE]not[/color] ([color=BLUE]setq[/color] pt1 ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify arrowhead location: "[/color]))))
       (   ([color=BLUE]progn[/color]
               ([color=BLUE]setq[/color] ent ([color=BLUE]entlast[/color]))
               ([color=BLUE]command[/color] [color=MAROON]"_.arc"[/color] [color=MAROON]"_non"[/color] pt1)
               ([color=BLUE]while[/color] ([color=BLUE]=[/color] 1 ([color=BLUE]logand[/color] 1 ([color=BLUE]getvar[/color] 'cmdactive)))
                   ([color=BLUE]command[/color] [color=MAROON]"\\"[/color])
               )
               ([color=BLUE]eq[/color] ent ([color=BLUE]setq[/color] ent ([color=BLUE]entlast[/color])))
           )
       )
       (   ([color=BLUE]<[/color] ([color=BLUE]setq[/color] dis ([color=BLUE]vlax-curve-getdistatparam[/color] ent ([color=BLUE]vlax-curve-getendparam[/color] ent))) len)
           ([color=BLUE]entdel[/color] ent)
           ([color=BLUE]princ[/color] [color=MAROON]"\nArc too short to accommodate arrowhead block."[/color])
       )
       (   ([color=BLUE]progn[/color]
               ([color=BLUE]setq[/color] ocs ([color=BLUE]trans[/color] '(0.0 0.0 1.0) 1 0 [color=BLUE]t[/color])
                     pt2 ([color=BLUE]if[/color] ([color=BLUE]equal[/color] ([color=BLUE]trans[/color] pt1 1 0) ([color=BLUE]vlax-curve-getstartpoint[/color] ent) 1e-4)
                             ([color=BLUE]vlax-curve-getpointatdist[/color] ent len)
                             ([color=BLUE]vlax-curve-getpointatdist[/color] ent ([color=BLUE]-[/color] dis len))
                         )
               )          
               ([color=BLUE]entmake[/color]
                   ([color=BLUE]list[/color]
                      '(000 . [color=MAROON]"INSERT"[/color])
                       ([color=BLUE]cons[/color] 002 blk)
                       ([color=BLUE]cons[/color] 010 ([color=BLUE]trans[/color] pt1 1 ocs))
                       ([color=BLUE]cons[/color] 050 ([color=BLUE]angle[/color] ([color=BLUE]trans[/color] pt2 0 ocs) ([color=BLUE]trans[/color] pt1 1 ocs)))
                       ([color=BLUE]cons[/color] 041 scl)
                       ([color=BLUE]cons[/color] 042 scl)
                       ([color=BLUE]cons[/color] 043 scl)
                       ([color=BLUE]cons[/color] 210 ocs)
                   )
               )
           )
       )
       (   ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nUnable to insert \""[/color] blk [color=MAROON]"\" block."[/color]))
           ([color=BLUE]entdel[/color] ent)
       )
   )
   ([color=BLUE]princ[/color])
)

[color=GREEN];; Import Block Definition  -  Lee Mac[/color]
[color=GREEN];; blk - [str] Block name, drawing filename, or full filepath[/color]
[color=GREEN];; Returns: [str] Block name if successful, else nil[/color]

([color=BLUE]defun[/color] LM:importblock ( blk [color=BLUE]/[/color] bse cmd ext pth )
   ([color=BLUE]setq[/color] pth ([color=BLUE]vl-string-translate[/color] [color=MAROON]"/"[/color] [color=MAROON]"\\"[/color] ([color=BLUE]vl-filename-directory[/color] blk)) 
         ext ([color=BLUE]cond[/color] (([color=BLUE]vl-filename-extension[/color] blk)) ([color=MAROON]".dwg"[/color]))
         bse ([color=BLUE]vl-filename-base[/color] blk)
   )
   ([color=BLUE]if[/color] ([color=BLUE]not[/color] ([color=BLUE]or[/color] ([color=BLUE]=[/color] [color=MAROON]""[/color] pth) ([color=BLUE]wcmatch[/color] pth [color=MAROON]"*\\"[/color])))
       ([color=BLUE]setq[/color] pth ([color=BLUE]strcat[/color] pth [color=MAROON]"\\"[/color]))
   )
   ([color=BLUE]cond[/color]
       (   ([color=BLUE]tblsearch[/color] [color=MAROON]"block"[/color] bse) bse)
       (   ([color=BLUE]setq[/color] blk ([color=BLUE]findfile[/color] ([color=BLUE]strcat[/color] pth bse ext)))
           ([color=BLUE]setq[/color] cmd ([color=BLUE]getvar[/color] 'cmdecho))
           ([color=BLUE]setvar[/color] 'cmdecho 0)
           ([color=BLUE]command[/color] [color=MAROON]"_.-insert"[/color] blk [color=BLUE]nil[/color])
           ([color=BLUE]setvar[/color] 'cmdecho cmd)
           ([color=BLUE]if[/color] ([color=BLUE]tblsearch[/color] [color=MAROON]"block"[/color] bse)
               bse
           )
       )
   )
)

([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color])

The above should also perform successfully under all UCS & View settings.

Posted

Lee,

 

That works great, but it seems the arcleader is set to come in on current leader. where is the line that specifies to come in on the current leader? I want to specify a specific layer to draw the arc leader on.

 

Thank you again,

Jim

Posted

never mind, I figured out how to change the layer. I added at "setvar" statement to the beginning of the program.

  • 1 month later...
Posted

Lee,

 

I have one more question about this Arc Leader Lisp that works great, what would be the add on to the lisp to instruct AutoCAD after placing the Arc Leader to add a text box to the end of the line?

 

Thanks as always for your guidance,

Jim

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...