Jump to content

Create Multileader with default text using lisp


Recommended Posts

Posted

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]
Posted (edited)
(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
Posted (edited)
  On 9/10/2018 at 12:24 PM, 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.

Expand  

Thaaaanks!. It helps me alot! :)

Edited by joemcanciller
Posted
  On 9/11/2018 at 1:35 AM, joemcanciller said:

Thaaaanks!. It helps me alot! :)

Expand  

 

Your welcome.

Posted
  On 9/11/2018 at 6:17 AM, dlanorh said:

 

Your welcome.

Expand  

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

Posted
  On 9/13/2018 at 5:23 AM, 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. :)

Expand  

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. 

Posted
  On 9/13/2018 at 5:32 AM, 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. 

Expand  

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

Posted
  On 9/13/2018 at 5:32 AM, 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. 

Expand  

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

Posted (edited)
  On 9/13/2018 at 5:55 AM, joemcanciller said:

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

Expand  

 

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
Posted (edited)

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
Posted
  On 9/13/2018 at 9:54 AM, 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.

Expand  

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

pic4.JPG

pic3.JPG

  • 1 year later...
Posted

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

 

 

 

Posted (edited)

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.lspFetching info...

Edited by BIGAL
Posted

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 

 

 

  • 3 years later...
Posted
  On 9/19/2018 at 5:41 AM, joemcanciller said:

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

pic4.JPG

pic3.JPG

Expand  

 

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

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