We created an AutoLISP program to create leader to label coordinate before. It will be very useful for surveyors who use vanilla AutoCAD. But you may want to use multileader instead of leader in your AutoLISP program. MLEADER is neat, and you can have more control and flexibility with it.
The problem is it uses multiline text, not single line text in leader. When working with multiline text, we press [enter] when we want to add another text line. But using “” in AutoLISP to simulate pressing enter, it will not work. When we use “” AutoCAD thinks we want to end the command. But not adding new line.
I posted a reply in the comment section, but just in case you miss it I write it as a post. To solve this, we need to use ANSI character to add a new line. chr 10 will add new line (or line feed) to our variable.
Let’s take an example. We add that character to our string variable:
(setq ptcoordN (strcat "N=" y))
(setq ptcoordE (strcat "E=" x))
(setq ptcoordN (strcat ptcoordN (chr 10) ptcoordE))
The first and second line will get x and y value, then add prefix. The 3rd line will combine them both. That AutoLISP code will combine N coordinate, new line, then place E coordinate there.
The complete AutoLISP code will be:
(defun c:cnlabel (/ p x y ptcoordN ptcoordE textloc oldprec)
(setq oldprec (getvar "LUPREC"))
(setvar "LUPREC" 4)
(while ; start while loop
(setq p (getpoint "
Pick Point to Label:")) ; asking user to click point to label and save it
(setq textloc (getpoint p "
Pick Text Location:")) ;asking user to click text location
(setq x (rtos (car p)))
(setq y (rtos (cadr p)))
(setq ptcoordN (strcat "N=" y))
(setq ptcoordE (strcat "E=" x))
(setq ptcoordN (strcat ptcoordN (chr 10) ptcoordE))
(command "mleader" p textloc ptcoordN) ;ativate label command and use the input
(setvar "LUPREC" oldprec)
(princ)
)
)
I don’t know if there is other solution for this. If you know the other way, please share it here!
dear Edwin
i have decided to use the MULTILINE comand to draw wall lines ( i am an architect) the autocad setup allows you to set line spacing, colour, all on one layer,,, is there any way to do this with lines on specific layers,
any help would be apprecited, Bernie
Bernie,
You can’t have a line like that. You need to override the line properties. Or you can create a line with custom properties, then drag it to tool palettes so you can use it later easily.
just use ‘txt2mtxt’ to change a single line text item to multiline text.