Jump to content

Create Multileader with default text using lisp


joemcanciller

Recommended Posts

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]
Link to comment
Share on other sites

(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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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. :)

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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! :)))

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 year later...

Hi every body,

 

I try to build the same thing but i have not undertand how can i defined the list and assign the value as a variable.

 

Thank's a lot for you help

 

 

 

Link to comment
Share on other sites

Here is an example this uses the approach of a library function that it loads the create dcl as required. Change last 2 numbers for width and height to suit

Code 

; code use
(if (not AHlstbox)(load "Listbox-AH.lsp"))
(setq ans (ahlstbox "Pick a number" (list "150" "200" "225" "250" "300" "375" "450" "600") 20 10)))
; ans is returned = item selected of the list
(defun c:mla ( / ml_txt)
(if (not AHlstbox)(load "Listbox-AH.lsp"))
(setq ans (ahlstbox "Pick a number" (list "AL150" "AL200" "AL225" "AL250" "AL300" "AL375" "AL450" "AL600") 20 10)))
  (command "_mleader" pause pause pause ans)
);end_defun  

 

Listbox-AH.lsp

Edited by BIGAL
Link to comment
Share on other sites

Hi Bigal, thx a lot for your help!

The only Thing is the selected value in the pickbox works but the mleader function is not loaded 

 

 

Link to comment
Share on other sites

  • 3 years later...
On 9/19/2018 at 12:41 PM, joemcanciller said:

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

pic4.JPG

pic3.JPG

 

Hi, i'm new with lisp program. Could you please post your lisp code ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...