Leaders and temporarily changing mtext justification.
I have created a quick lisp routine for the office that allows me to create a curved leader, code to follow. How do I adjust the justification of the mtext object, the default is to create the text with the justification set to Bottom left or right depending on the side of the arrow that the text is on. I would like to have the text created with either middle left of middle right, but I am lost.
Once that is solved, I can see another pit that I am about to fall into with this; in order to determine which side to justify the text on, I have to compare the points that the user has picked. Depending on the delta X between the start and last points I can determine which side the text will be placed on and which side to justify the text to. This is easy enough to do, but the problem is, I could ask the user to pick, let's say three points, a start, next point and a to point, at the to point, I insert the text; I have now limited the user to only three points, which does not work in all situations....
I am thinking that the solution to the above could be to create a point list, with a while loop that keeps asking for points (and appending them to the list) until the user hits enter or right clicks. Then it is a matter of parsing the list, comparing the first and last members of the list, setting the justification accordingly and then creating the leader...
What I am attempting to do is emulate the autocad qleader command, If I can get this to work, I can then pull the qleader settings from the drawing database instead of manually entering them in the code...
[code](defun c:q1 ()
(setq pdimtad (getvar "dimtad"))
(setvar "dimtad" 0)
(setq startpt (getpoint "\nStart of leader: "))
(setq cornerpt (getpoint startpt "\nNext point: "))
(ScottSaveOSnaps)
(command ".leader" startpt cornerpt "f" "sp" "e")
(ScottResetOsnaps)
(setvar "dimtad" pdimtad)
)[/code]0
Comments
-
To understand what is wrong with your code try the code below, comment out the while loop and look for "Done" in the command line history.
[code](defun c:q1 ( / cornerpt pdimtad startpt)
(setq pdimtad (getvar "dimtad"))
(setvar "dimtad" 0)
(setq startpt (getpoint "\nStart of leader: "))
(setq cornerpt (getpoint startpt "\nNext point: "))
(ScottSaveOSnaps)
(command "_.leader" startpt cornerpt "_format" "_spline" "_exit")
(ScottResetOsnaps)
(while (> (getvar "cmdactive") 0)
(command pause)
)
(setvar "dimtad" pdimtad)
(princ "\nDone")
(princ)
)
[/code]0
This discussion has been closed.