Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Active Member
rfrod
Posts: 10
Registered: ‎06-09-2005
Message 1 of 5 (132 Views)

Leaders

132 Views, 4 Replies
03-28-2009 07:08 AM
How do you unexplode a leader by using lisp
Distinguished Contributor
curmudgeon
Posts: 156
Registered: ‎05-22-2007
Message 2 of 5 (132 Views)

Re: Leaders

03-28-2009 08:38 AM in reply to: rfrod
I use my own leader command because I like to, and I have not kept up with all the different forms a leader can take, but....

I assume you want to recreate a leader that has been exploded long enough ago that undo is of no help.

I can tell you what I could do if it were one of my leaders, since I know how I put them together in the first place.
My arrow head and lines are one continuous polyline, I just play with the width to the polyline to create an arrow head. When exploded, I could make a selection set of the lines from the exploded polyline and the text entities. Then I could recreate the polyline from the point data, if i were real clever - and reuse or remake the text.

But it would be far easier to just remake the leader.

I have my leader routine set to use a default text of the previous leader for all those times I have to have the same text twice. I also have a text matching routine where I pick one piece of text and then I can select other text to match that. But I save mine in a variable I understand, and this is the same variable I use for default text.

Anything I have here I would share, but I am wondering if you want to go to this much effort.


roy
Active Member
rfrod
Posts: 10
Registered: ‎06-09-2005
Message 3 of 5 (132 Views)

Re: Leaders

03-28-2009 12:35 PM in reply to: rfrod
Thanks. I have m own leader command as well. What i do is this:
(SETQ PT1 (GETPOINT "Leader start: "))(TERPRI)
(SETQ PT2 (GETPOINT PT1 "Next point: "))(TERPRI)
(COMMAND "DIM1" "LEADER" PT1 PT2 ^C^C^C)
then the rest of the program. The problem is that if I move the test with the stretch command, my leader does not adjust to the
move since it is exploded. That is why i ned to somehow unexplode it. "Qleader" doesn't work either.
Distinguished Contributor
curmudgeon
Posts: 156
Registered: ‎05-22-2007
Message 4 of 5 (132 Views)

Re: Leaders

03-28-2009 02:12 PM in reply to: rfrod
when I said I had my own leader command, I meant lisp. check out the attached file to see the difference.

that is old code, and ugly code. there is superfluous stuff like a font that you probably won't have for the text. but if you replace the
(cons 1 .....) with something you want to use, you can play with this and see if you like it.

I am betting you may not know what to put there. pick a piece of text in a drawing that would look right to you, and
(setq it (entget (car (entsel))))

then F2 to see the whole enchilada, or (assoc 1 it).
(cdr (assoc 1 it)) is what you want to see in the (cons 1 ....) above.

IF I REMEMBER CORRECTLY, the arrow head and first segment is a single lwpolyline, the horizontal is a line segment, and the text is middle left justified MTEXT. the horizontal line is forced horizontal.

have to go to town and pick up youngest son. play with the routine if you fancy.


roy
*Expert Elite*
Kent1Cooper
Posts: 5,418
Registered: ‎09-13-2004
Message 5 of 5 (132 Views)

Re: Leaders

03-30-2009 01:33 PM in reply to: rfrod
The leader not adjusting when the Text is moved could be the case if the Leader is exploded, but also if it isn't, but is just not associated with the piece of Text or Mtext.

But the Leader created by that code is ending up effectively "exploded," because you're using the Leader option inside a Dim1 command, rather than the true Leader command. The former does *not* make a real Leader, at least not for me in ACAD2004 -- it makes a Block [the arrowhead] and Line(s).

In other words, it's not really exploded, but rather was never a true Leader in the first place. That being the case, there wouldn't be any hope of "unexploding" it. Even given a true Leader that has been exploded, I don't see any way it could be unexploded [other than by undoing back past the explosion], any more than an exploded Block's resulting drawing entities could be re-assembled into a Block insertion again. How would a routine figure out where those parts came from, or which entities belong? I suspect you would just need to make it over again, and get rid of the exploded parts.

But there shouldn't be any need. If you want to end up with a one-line-segment Leader, with Text that is associated with it so that the Leader will adjust with the Text, I'm not sure what most of your own Leader command is doing for you. You may as well forget the variables, and the spelling out of the prompts yourself, and just do

(command "leader" pause pause "")

[or maybe a Qleader command tailored to your Qleader settings]. That will leave you at the prompt for text content. The Leader will be a real one, not exploded, and it will adjust when the Text is moved. Depending on what "the rest of the program" does, it might be necessary to adjust that further, for example if you want to restrict the User to one line of Text.

You could also leave the user all the options that Leader offers, by doing this:

(command "leader")
(while (> (getvar 'cmdactive) 0)
(command pause)
)

[or likewise with Qleader], which will just start up a Leader [or Qleader] command and then wait for user input until it's completed, before going on to the rest of the routine.

[And by the way, the ^C^C^C in there is not valid Lisp code -- it's macro language. It "works" to end the Dim1 Leader sub-command simply because Lisp doesn't have any idea what to do with it; you could use MarilynMonroe instead, with exactly the same result.]

--
Kent Cooper


rfrod wrote:...

.... I have m own leader command as well. What i do is this:
(SETQ PT1 (GETPOINT "Leader start: "))(TERPRI)
(SETQ PT2 (GETPOINT PT1 "Next point: "))(TERPRI)
(COMMAND "DIM1" "LEADER" PT1 PT2 ^C^C^C)
then the rest of the program. The problem is that if I move the test with the stretch command, my leader does not adjust to the
move since it is exploded. That is why i ned to somehow unexplode it. "Qleader" doesn't work either.
Kent Cooper
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.