Jump to content

Recommended Posts

Posted

Hi,

 

I have this part of the lisp that makes a leader.

I use ACAD 2008/2010. it works for me but when I execute it at another desktop here in the office, it doesn't work.

It behaves like, it asks for the three points as in the lisp but then stops when the text is about to be entered.

Why is it working for me but not for him. We use the same desktops, same ACADs. Really strange. Is there some option in the settings that prevent that leader to be succesfully executed?

 

here is the codE:

(defun leader(/ p1 p2 p3)




 (setq p1 (getpoint "\nstart point: ")
p2 (getpoint p1 "\nsecond point: ")
 )
 (grdraw p1 p2 1 1)
 (setq p3 (getpoint p2 "\ntext: "))
 (command "_leader" p1 p2 p3 "" "" "" "")
 (redraw)
)

Posted

You'd better change the setting of the leader to 2points or much better to include that among your codes to let it run normally in all other Cad leader settings.

 

Good luck.

Posted (edited)

According to the code you've posted, this *should* be all you need:

 

(defun c:FOO (/ p1 p2)
 (if (setq p1 (getpoint "\n  >>  Specify Start Point: "))
   (progn
     (setq p2 (getpoint p1 "\n  >>  Specify End Point: "))
     (command "._leader" p1 p2 "" pause)))
 (princ))

Edited by BlackBox
Posted

Nice work Renderman.

 

But the name of the routine is one of cad's standard commnands.and when loading the routine, cad would start with cad's command and

according to what I have mentioned earlier, the routine would also consider Cad's commands settings first, so if number of points for Qleader is toggled to no limits

so the qleader won't stop for inserting texts at all.

 

here is mine if you would like to use .

(defun c:LEAD (/ p1 p2)
 (if (and (setq p1 (getpoint "\n Specify Start Point: "))
          (setq p2 (getpoint p1 "\n Specify End Point: "))
   )
 (command "._leader" p1 p2 "" pause))
 (princ)
 )

 

Thanks

Posted
the name of the routine is one of cad's standard commnands.

 

 

Thanks for pointing that out, it was an oversight on my part. The code has been corrected in my earlier post.

Posted

Not sure if you need text or not, but my entry:

 

(defun c:test ( / p1 p2 ) (vl-load-com)

 (if (and (setq p1 (getpoint "\nPick First Point: "))
          (setq p2 (getpoint "\nPick Next Point: " p1))
     )
   (vlax-invoke
     (vlax-get (vla-get-ActiveDocument (vlax-get-acad-object))
       (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace)
     )
     'AddMLeader (append p1 p2) 0
   )
 )

 (princ)
)

Posted
Not sure if you need text or not, but my entry:

 

(defun c:test ( / p1 p2 ) (vl-load-com)

(if (and (setq p1 (getpoint "\nPick First Point: "))
(setq p2 (getpoint "\nPick Next Point: " p1))
)
(vlax-invoke
(vlax-get (vla-get-ActiveDocument (vlax-get-acad-object))
(if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace)
)
'AddMLeader (append p1 p2) 0
)
)

(princ)
)

 

Lee, here the "tail" of the leader always goes to the left, even when the slope of the leader is to the right.

I assume I have something screwed up, or is there a bug in the prog ?

Steve

Posted
Lee, here the "tail" of the leader always goes to the left, even when the slope of the leader is to the right.

I assume I have something screwed up, or is there a bug in the prog ?

Steve

 

Its very simple code Steve - just coded to create the leader object. If the user were to pursue this route, they would have to modify the leader to add text/change dogleg direction etc. I could add some more code to it, but I'll see which way the OP wants to proceed first.

Posted

Uhmm Lee ... that creates an MLeader. The OP wanted an old type QLeader. Not that I don't like MLeaders, but some want the older type due to some features not being easy with MLeaders. If you want to create the Leader entity through vla-AddLeader, you'd first need to create the MText entity then use that as an argument to the AddLeader method. Or add it to the leader's Annotation property afterward.

Posted

Two or three leader points with MText annotation prompt:

 

(defun c:Test (/ p1 p2 p3)
 (if (and (setq p1 (getpoint "\nSpecify leader starting point: "))
          (setq p2 (getpoint p1 "\nSpecify next point: "))
     )
   (progn
     (grdraw p1 p2 7 1)
     (setq p3 (getpoint p2 "\nSpecify next point <Annotation>: "))
     (redraw)
     (initdia)
     (if p3
       (command "_.leader" "_non" p1 "_non" p2 "_non" p3 "_A" "" "_M" "")
       (command "_.leader" "_non" p1 "_non" p2 "_A" "" "_M" "")
     )
   )
 )
 (princ)
)

  • Like 1
Posted

Mr. Alan.

 

Could you please tell why did you use the (initdia) since won't be any dialog to show with the leader command ?

 

Thanks

Posted
Mr. Alan.

 

Could you please tell why did you use the (initdia) since won't be any dialog to show with the leader command ?

 

Thanks

It's to initiate the MText editor (dialog). Part of the Leader command.

 

eg.

Command: leader

Specify leader start point:
Specify next point:
Specify next point or [Annotation/Format/Undo] <Annotation>: a

Enter first line of annotation text or <options>:
Enter an annotation option [Tolerance/Copy/Block/None/[color=red]Mtext] <Mtext>: [/color]m

Posted

That's really nice, I've forgotten about that Mtext dialog .

 

Thank you so much.

Posted
That's really nice, I've forgotten about that Mtext dialog .

 

Thank you so much.

I've never actually used Leader; QLeader was around in r14 (when I started) and I just used that (much better) and the newly introduced (as of 2008) MLeader.

  • 12 years later...
Posted

Can anyone give me a example for a leader lisp expression that has two points to draw and change the arrow head type as dot blank

Posted
10 hours ago, Akashak said:

Can anyone give me a example for a leader lisp expression that has two points to draw and change the arrow head type as dot blank

Create an mleader style with dot blank as the arrow type then set it current like so: 

(setvar 'cmleaderstyle "YourStyleName")

 

Posted


(defun c:FA ;| FlipArrows |; (/ Ent VlaObj )
  (vl-load-com)
  (while (setq Ent (entsel "Select leader: " ) )
    (progn
      (vl-load-com )
      (setq VlaObj (vlax-ename->vla-object (car Ent )) )
      (if (= (vla-get-objectName VlaObj ) "AcDbLeader")
        (cond
          ((= (vla-get-ArrowheadBlock VlaObj ) "" ) (vla-put-ArrowheadBlock VlaObj "Integral" ) )
          ((= (vla-get-ArrowheadBlock VlaObj ) "Integral" ) (vla-put-ArrowheadBlock VlaObj "DotBlank" ) )
      ((= (vla-get-ArrowheadBlock VlaObj ) "DotBlank" ) (vla-put-ArrowheadBlock VlaObj "_Dot" ) )
      ((= (vla-get-ArrowheadBlock VlaObj ) "Dot" ) (vla-put-ArrowheadBlock VlaObj "DotSmall" ) )
      ((= (vla-get-ArrowheadBlock VlaObj ) "DotSmall" ) (vla-put-ArrowheadBlock VlaObj "BoxBlank" ) )
          ((= (vla-get-ArrowheadBlock VlaObj ) "BoxBlank" ) (vla-put-ArrowheadBlock VlaObj "ArchTick" ) )
      ((= (vla-get-ArrowheadBlock VlaObj ) "ArchTick" ) (vla-put-ArrowheadBlock VlaObj "" ) )
      ((= (vla-get-ArrowheadBlock VlaObj ) "" ) (vla-put-ArrowheadBlock VlaObj "" ) )
      ((= (vla-get-ArrowheadBlock VlaObj ) "" ) (vla-put-ArrowheadBlock VlaObj "" ) )
;;          ((= (vla-get-ArrowheadBlock VlaObj ) "DotSmall" ) (vla-put-ArrowheadBlock VlaObj "" ) )
          (t nil)
        )
        (princ "..wrong object type ! " )
      )
      (if (not (vlax-object-released-p VlaObj )) (vlax-release-object VlaObj ) ( ) )
    )
  )
  (princ)
)

FA.LSP

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...