Jump to content
joemcanciller

Create Multileader with default text using lisp

Recommended Posts

joemcanciller

Hi guys. Im new with this lisp thing. Is it possible to create mleader with default text using lisp? For example, I want the text to be "Aluminum" without typing in CAD. Im stucked with this code. It allows me to create the leader only without the text. Thanks in advance.

 

(defun c:xm ()
  (setvar 'CMDECHO 0)
  (command "-layer" "m"    "text" "c" "4" "" "" "cmleaderstyle" "standard")
  (setvar 'CMDECHO 1)
  (initcommandversion)
  (command ".mleader")
  (while (> (getvar 'cmdactive) 0)
    (command pause)
  )
  (princ)
)[/CODE]

Share this post


Link to post
Share on other sites
dlanorh
(defun c:mla ( / ml_txt)
  (setq ml_txt "Aluminium")
  (command "_mleader" pause pause ml_txt)
);end_defun  

Welcome to CADTutor. This should do it. This is for a straight 2 point multileader. If your mleader is more than a straight line then add extra pauses.

 

eg:

 

(defun c:mla ( / ml_txt)
  (setq ml_txt "Aluminium")
  (command "_mleader" pause pause pause ml_txt)
);end_defun  

The pause allows you to select a point as per the mleader command.

 

You will need to set the required multi-leader style before typing "mla" to start.

Edited by dlanorh
  • Like 1

Share this post


Link to post
Share on other sites
joemcanciller
13 hours ago, SLW210 said:

Please read the [URL="http://www.cadtutor.net/forum/showthread.php?t=9184"]Code Posting Guidelines[/URL] and have your Code to be included in Code Tags.[NOPARSE]


Your Code Here[/NOPARSE][/CODE] = [CODE]Your Code Here[/CODE]

Thanks for the reminder. Ill do better next time. :)

Share this post


Link to post
Share on other sites
joemcanciller
13 hours ago, dlanorh said:

(defun c:mla ( / ml_txt)
  (setq ml_txt "Aluminium")
  (command "_mleader" pause pause ml_txt)
);end_defun  

Welcome to CADTutor. This should do it. This is for a straight 2 point multileader. If your mleader is more than a straight line then add extra pauses.

 

eg:

 


(defun c:mla ( / ml_txt)
  (setq ml_txt "Aluminium")
  (command "_mleader" pause pause pause ml_txt)
);end_defun  

The pause allows you to select a point as per the mleader command.

 

You will need to set the required multi-leader style before typing "mla" to start.

Thaaaanks!. It helps me alot! :)

Edited by joemcanciller

Share this post


Link to post
Share on other sites
dlanorh
4 hours ago, joemcanciller said:

Thaaaanks!. It helps me alot! :)

 

Your welcome.

Share this post


Link to post
Share on other sites
joemcanciller
On 11/09/2018 at 14:17, dlanorh said:

 

Your welcome.

Hello again, Im thinking something with your code. Is it possible to have a drop down list in the text? Like selecting text to display from the list of texts, so that I can work with only one command "c:mla" then select text to display for example. Thanks in advance. :)

Share this post


Link to post
Share on other sites
dlanorh
5 minutes ago, joemcanciller said:

Hello again, Im thinking something with your code. Is it possible to have a drop down list in the text? Like selecting text to display from the list of texts, so that I can work with only one command "c:mla" then select text to display for example. Thanks in advance. :)

It is quite easy and can be done using dynamic input/command line or via DCL. If there are more than 3-5 to select from then DCL is probably the better option. 

Share this post


Link to post
Share on other sites
joemcanciller
16 minutes ago, dlanorh said:

It is quite easy and can be done using dynamic input/command line or via DCL. If there are more than 3-5 to select from then DCL is probably the better option. 

Is DCL same with LISP? I have no idea, sorry :( Can you set an example? Much appreciated man.

Share this post


Link to post
Share on other sites
joemcanciller
2 hours ago, dlanorh said:

It is quite easy and can be done using dynamic input/command line or via DCL. If there are more than 3-5 to select from then DCL is probably the better option. 

Thanks again! I did it! I discovered something new! :)))

Share this post


Link to post
Share on other sites
dlanorh
4 hours ago, joemcanciller said:

Is DCL same with LISP? I have no idea, sorry :(Can you set an example? Much appreciated man.

 

DCL is Dialog Control Language. If you know VBA it's akin to a form, only you have to construct it yourself if you want something more than basic.

popup : dialog {
label = "Popup List" ;

: popup_list {
label = "Choose Text : ";
key = "selection";
value = "5" ;
edit_width = 20;
}

ok_cancel ;

}

This is a DCL dialog, shamelessly stolen from the AfraLisp site and adapted. ;)

 

You can save it as a seperate file (*.DCL) or write it as a temp file from lisp. Once loaded you supply and fill the list and dictate what happens when OK or Cancel is pressed, and what happens when a selection is made from the list. You then display the dialog and wait for the user to interact.

Edited by dlanorh
  • Like 1

Share this post


Link to post
Share on other sites
BIGAL

Rather than writing a DCL for every program about picking from lists you use a library approach. I posted earlier today an example using lee-macs listboxV1-2.lsp.

 

 

 

 

Edited by BIGAL
  • Like 1

Share this post


Link to post
Share on other sites
joemcanciller
On 13/09/2018 at 17:54, dlanorh said:

 

DCL is Dialog Control Language. If you know VBA it's akin to a form, only you have to construct it yourself if you want something more than basic.


popup : dialog {
label = "Popup List" ;

: popup_list {
label = "Choose Text : ";
key = "selection";
value = "5" ;
edit_width = 20;
}

ok_cancel ;

}

This is a DCL dialog, shamelessly stolen from the AfraLisp site and adapted. ;)

 

You can save it as a seperate file (*.DCL) or write it as a temp file from lisp. Once loaded you supply and fill the list and dictate what happens when OK or Cancel is pressed, and what happens when a selection is made from the list. You then display the dialog and wait for the user to interact.

Thanks for the help.
This is what i've got. Im happy learning this thing. :)
 

pic4.JPG

pic3.JPG

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×