Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Expert Elite*
sbrusco
Posts: 1,180
Registered: ‎07-27-2000
Message 1 of 10 (870 Views)
Accepted Solution

Pick a Command Line Option in LSP - Same as Built In Commands

870 Views, 9 Replies
11-18-2013 05:53 AM

Hi All,

 

I like that Autodesk now allows us to just pick a command's option from the command line instead of typing a letter in the option. For example, when drawing a rectangle we're prompted to "Specify first corner point or [Chamfer Elecation Fillet Thickness Width]" and if we wanted to draw fillets on the rectangle we can simply PICK that option from the prompt in the command line OR enter an "F" and return.

 

Is there a way we can use this functionality in our custom programs?

 

TIA,

Sal



sbrusco wrote:

Hi,

 

You are all correct and thanks for the input. Almost all my code does work as you indicate and as i expected except for this section which i'm sure is becuse it is a GETKWORD function. Just the same, how can i get these options to be "pickable" on the command line and even appear in the pop up menu by the cursor...

 

 


Not sure if it an be done with cad versions lower than 2012 or is it 2013?

 

One thing though

" [Access/Extru/Fast/FLash/Panel/Sealant] <Flash>)"

 

Use "[...]" symbol instead of "(..)"

 

All i'm saying is , if your cad version is capable of that features then it will be "pickable" as long as you sue the right syntax

 

*Expert Elite*
Lee_Mac
Posts: 1,262
Registered: ‎12-29-2009
Message 2 of 10 (867 Views)

Re: Pick a Command Line Option in LSP - Same as Built In Commands

11-18-2013 05:59 AM in reply to: sbrusco

Yes, if you format your prompts in the following way:

 

 

[Option1/Option2/Option3] <Option1>

 

They should appear in the same way as standard AutoCAD prompts.

Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)
Expert Elite
With Mathematics there is the possibility of perfect rigour, so why settle for less?
*Expert Elite*
sbrusco
Posts: 1,180
Registered: ‎07-27-2000
Message 3 of 10 (860 Views)

Re: Pick a Command Line Option in LSP - Same as Built In Commands

11-18-2013 06:09 AM in reply to: Lee_Mac

Hi Lee_Mac,

 

Thanks for your VERY quick response.

 

You are correct that formatting the prompt that way they will "appear" the same as the standard AutoCAD prompts but I want them to ACT like the standard AutoCAD prompts in that I will be able to PICK them from the command line instead of entering their key letter(s). In other words, using the example in the OP, if while at the rectangle command prompt, I can move the cursor over the "Fillet" option and pick. Real nice. How can I get this in my custom code?

 

Sal


*Expert Elite*
hmsilva
Posts: 3,191
Registered: ‎12-17-2004
Message 4 of 10 (845 Views)

Re: Pick a Command Line Option in LSP - Same as Built In Commands

11-18-2013 06:46 AM in reply to: sbrusco

 Hi sbrusco,

 

something like this perhaps

 

(setvar "errno" 0)
 (initget "Chamfer Elecation Fillet Thickness Width")
 (setq ans (getpoint "\n Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/Width]: "))
 (cond
 ((= 'list (type ans))
 (getcorner ans "\n Specify other corner: ") )
 ((= "Chamfer" ans)
 (princ "\nDo the Chamfer stuff!") )
 ((= "Elevation" ans)
 (princ "\nDo the Elevation stuff!") )
 ((= "Fillet" ans)
 (princ "\nDo the Fillet!") )
  ((= "Thickness" ans)
 (princ "\nDo the Thickness stuff!") )
   ((= "Width" ans)
 (princ "\nDo the Width stuff!") )
 )

HTH

Henrique

*Expert Elite*
Lee_Mac
Posts: 1,262
Registered: ‎12-29-2009
Message 5 of 10 (843 Views)

Re: Pick a Command Line Option in LSP - Same as Built In Commands

11-18-2013 06:46 AM in reply to: sbrusco

sbrusco wrote:

You are correct that formatting the prompt that way they will "appear" the same as the standard AutoCAD prompts but I want them to ACT like the standard AutoCAD prompts in that I will be able to PICK them from the command line instead of entering their key letter(s).


If you have formatted the prompts as I have described, then they should act the same - at least, they do for me.

 

Here is a quick example for you to test:

 

(defun c:test ( )
    (initget "Alpha Beta Gamma")
    (getkword "\nChoose an option [Alpha/Beta/Gamma] <Alpha>: ")
)

 

Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)
Expert Elite
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Mentor
bhull1985
Posts: 438
Registered: ‎07-17-2013
Message 6 of 10 (829 Views)

Re: Pick a Command Line Option in LSP - Same as Built In Commands

11-18-2013 06:51 AM in reply to: Lee_Mac

Here's confirmation for what lee and hmsilva posted ...in autocad 2012 at least

Displays the floating menu next to the cursor and the initget arguments are mouse clickable.

In Lee's example, I could click on alpha beta and/or gamma just as though I had typed in the uppercase letter.

 

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Contributor
lkcadway
Posts: 17
Registered: ‎12-26-2008
Message 7 of 10 (801 Views)

Re: Pick a Command Line Option in LSP - Same as Built In Commands

11-18-2013 08:18 PM in reply to: sbrusco

in Asian charset , you would write prompt like this :

;;...

(initget "0 1 2 3 A E")
(setq sMsg "\nChoose an option or [图层(0)/文字样式(1)/尺寸标注样式(2)/坐标系(3)/设置 (A)/退出(E)]:")

;;...

 

 

*Expert Elite*
sbrusco
Posts: 1,180
Registered: ‎07-27-2000
Message 8 of 10 (786 Views)

Re: Pick a Command Line Option in LSP - Same as Built In Commands

11-19-2013 03:50 AM in reply to: bhull1985

Hi,

 

You are all correct and thanks for the input. Almost all my code does work as you indicate and as i expected except for this section which i'm sure is becuse it is a GETKWORD function. Just the same, how can i get these options to be "pickable" on the command line and even appear in the pop up menu by the cursor...

 

Yeah, i know, i want it all. But i know you guys can help me get it all. You're the best.

 

Sal

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  (INITGET
    (+ 2 4)    ; no zeros or neg numbers
    "ACCESSORY,A EXTRUSION,E FASTENER,F FLASHING,FL PANEL,P SEALANT,S"
  )
  (SETQ newLay (GETKWORD
   (STRCAT
     "\nMove object to layer:"
     " (Access/Extru/Fast/FLash/Panel/Sealant <Flash>)"
   )
        )
  )
  ;; set user entry default
  (IF (NOT newLay)
    (SETQ newLay "FLASHING")
  )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


*Expert Elite*
pbejse
Posts: 2,502
Registered: ‎11-24-2009
Message 9 of 10 (780 Views)

Re: Pick a Command Line Option in LSP - Same as Built In Commands

11-19-2013 04:00 AM in reply to: sbrusco

sbrusco wrote:

Hi,

 

You are all correct and thanks for the input. Almost all my code does work as you indicate and as i expected except for this section which i'm sure is becuse it is a GETKWORD function. Just the same, how can i get these options to be "pickable" on the command line and even appear in the pop up menu by the cursor...

 

 


Not sure if it an be done with cad versions lower than 2012 or is it 2013?

 

One thing though

" [Access/Extru/Fast/FLash/Panel/Sealant] <Flash>)"

 

Use "[...]" symbol instead of "(..)"

 

All i'm saying is , if your cad version is capable of that features then it will be "pickable" as long as you sue the right syntax

 

*Expert Elite*
sbrusco
Posts: 1,180
Registered: ‎07-27-2000
Message 10 of 10 (768 Views)

Re: Pick a Command Line Option in LSP - Same as Built In Commands

11-19-2013 04:10 AM in reply to: pbejse

Hi pbejse,

 

You are correct. As always, it helps to use the correct syntax. duh!

 

Anyway, that was the problem. Now it works as i want.

 

THANKS,

Sal


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!