Can I use LISP to call a different MLeader landing setting?

Can I use LISP to call a different MLeader landing setting?

murmanator
Advocate Advocate
1,234 Views
4 Replies
Message 1 of 5

Can I use LISP to call a different MLeader landing setting?

murmanator
Advocate
Advocate

I have a LISP function that sets the proper layer, sets the MLeaderstyle and prompts the user to enter the text. My problem is that when using this function, all my text is entered on a single line and my goal is to be able to use returns to format my text as I type. I find that when I just use the stock MLeader command and set it to Leader Landing First, I am able to enter multiple lines of MText and this solves my problem generally. I cant use this trick when using the LISP function because it is first asking me for the text, then doing the leader thing. So I am wondering if there is a way to set the Leader Landing First, click for that, then enter the text. Ideally this function would revert back to Leader Arrowhead First when complete. Below is my current function. Thanks for looking.

 

(defun c:plnot () (plnot))
(defun plnot (/ refltr)
(GV)
(ppa-L-POOLTXT)
(SETVAR 'CMLEADERSTYLE "mMLeaderPL")
(vl-cmdf "_.mleader" pause pause (setq refltr (getstring T "\n\t =>> Enter note : ")))
(SV)
(princ)
)

0 Likes
Accepted solutions (1)
1,235 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

@murmanator wrote:

.... when using this function, all my text is entered on a single line and my goal is to be able to use returns to format my text as I type. ....


That's because the first Enter in typing text content ends the (getstring) function [the T allows spaces inside a string, but not Enters], (vl-cmdf) verifies a complete set of inputs before it executes the command, and that (getstring) result constitutes a valid last input it needs, so it goes with it.  I expect [without testing] that if you do it this way, it will allow Enters withing the Mtext part of the command, and will let you complete that before going on to the (SV) function etc. afterwards:

....

(SETVAR 'CMLEADERSTYLE "mMLeaderPL")
(command "_.mleader")

(while (> (getvar 'cmdactive) 0) (command pause))
(SV)

....

 

EDIT:  no, that didn't work after all, in a quickie trial....

 

This is closer:

(command
  "_.mleader" pause pause (getstring T)
  "_.textedit" "_last"
)

 

but you have to pick at the end or hit the End key to get to where you can give another Enter at the end of the first line and continue to more lines.  Still, it does let you add more as you like, and after you're done, goes on to the next thing in the surrounding code.  Maybe there's code that can be fed in to do the End-and-Enter thing for you.

Kent Cooper, AIA
0 Likes
Message 3 of 5

hencoop
Advisor
Advisor

Reconstruct the input string to have \P where you want your new line.

(while (and (setq input (getstring T))(/= input ""))(setq input-lst (append input-lst (list input))))

(setq input-str (eval (cons strcat (mapcar '(lambda (x) (strcat x "\\P")) input-lst))))

 

P.S. I am confused about what you mean by "Landing".  There is a LandingGap, TextAttachmentDirection, and attachment types Text<location>AttachmentType where <location> is one of: Top, Bottom, Left, and Right.

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Version: 13.6.1963.0 Civil 3D 2024.4.1 Update Built on: U.202.0.0 AutoCAD 2024.1.6
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
0 Likes
Message 4 of 5

hencoop
Advisor
Advisor

I think it is necessary to put the constructed TextString into the MLeader after it is created and not as direct input during the creation.

That can be done thus assuming that the last entity is the Mleader (use another selection method if it is not): 

  (SETQ mleader_sel (ENTLAST))
  (IF (AND mleader_sel (EQ (CDR (ASSOC 0 (ENTGET mleader_sel))) "MULTILEADER"))
    (PROGN
      (VL-LOAD-COM)
      (SETQ this_obj (VLAX-ENAME->VLA-OBJECT mleader_sel))
      (VLAX-PUT-PROPERTY this_obj 'TextString input-str)
    )
  )

 

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Version: 13.6.1963.0 Civil 3D 2024.4.1 Update Built on: U.202.0.0 AutoCAD 2024.1.6
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
0 Likes
Message 5 of 5

murmanator
Advocate
Advocate

Thanks for the replies. Kent, that second but of code you provided is doing it. I just need to hit ENTER or put a space after I point for the leader. This wioll solve my problem, thank you again.

0 Likes