Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
sbrusco
3145 Views, 9 Replies

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

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


9 REPLIES 9
Message 2 of 10
Lee_Mac
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.

Message 3 of 10
sbrusco
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


Message 4 of 10
hmsilva
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

EESignature

Message 5 of 10
Lee_Mac
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>: ")
)

 

Message 6 of 10
bhull1985
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!
Message 7 of 10
lkcadway
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)]:")

;;...

 

 

Message 8 of 10
sbrusco
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")
  )

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


Message 9 of 10
pbejse
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

 

Message 10 of 10
sbrusco
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


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost