Jump to content

Optional User Input


miknick55

Recommended Posts

Hello,

I'm not exactly sure what the term is, but I want to learn how to add the option for user input, similar to many of the standard AutoCAD commands, such as "ZOOM" or "FILLET", that have a default setting with the option to modify the command in the middle.

 

Annotation 2019-10-01 102634.png

 

Example: call the fillet command and you can fillet immediately or press "M" for multiple fillets or "R" to change the radius and continue with the command. I have used the "getkword" function a little bit, but it seems like it behaves differently. How would I go about, for a simple example, adding the option to press "M" to add "MULTIPLE" to this program which just changes the current layer, calls the "POINT" command and pauses for location input and then changes the layer back. I want to have the option to call "vportpoint" and be able to have the option to press "M" for multiple, and maybe "T" or something for "M2P", if that's possible.

(defun c:vportpoint ( / oldlayer)
  (setq oldlayer (getvar "clayer"))
  (command "-layer" "set" "_VPORT" "")
  (command "point" pause)
  (setvar "clayer" oldlayer)
  
   (princ)
  )

If you have done something like this with a custom lisp command before your help would be much appreciated!

 

Thank you,

Michael

Link to comment
Share on other sites

A Simple search of "Keywords" in AutoCAD help resulted with this forum answer from Kent Copper:

 

Quote

If you construct the prompt with the options in square brackets with initial letters matching a preceding (initget) function's options, and with forward-slash separators, they will do that as in regular AutoCAD commands.  An example, from my MakeMore.lsp routine, when the selected object you want to Make More of is a LWPolyline, offering options for the different commands that can make them, i.e. that might have been what made the one you selected:

 

    (initget "PLine Rectangle POlygon Donut Cloud Boundary Sketch")
    (setq
      S2
        (getkword
          (strcat
            "\nPolyline Type [PLine/Rectangle/POlygon/Donut/Cloud/Boundary/Sketch] <"
            S1
            ">: "
          ); strcat
        ); getkword
      S2 (cond (S2) (S1)); use User entry, or default for Enter
    ); setq 
 

Kent1Cooper
Expert Elite
2019-03-12

 

This works with any of the (getxxx) functions in AutoLISP.

Edited by pkenewell
Link to comment
Share on other sites

Another approach to kents good work.  Multi getvals.lsp is available in download area.

 


(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (= but nil)(setq but 1))
(setq ans (ah:butts but "V"   '("Please choose" "PLine" "Rectangle" "POlygon" "Donut" "Cloud" "Boundary" "Sketch")))

 

image.png.1a88a7bf99fa3dd2a7f4105e9ceca294.png

 

 

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