Optional user input

Optional user input

Anonymous
Not applicable
3,036 Views
26 Replies
Message 1 of 27

Optional user input

Anonymous
Not applicable

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

0 Likes
Accepted solutions (2)
3,037 Views
26 Replies
Replies (26)
Message 21 of 27

Anonymous
Not applicable

sea.haven

Oh great! It's not exactly what I was looking for in this thread, but I am curious about it. Yes, please share!

 

Thanks,

Michael

0 Likes
Message 22 of 27

Sea-Haven
Mentor
Mentor

If you have any questions just post

Message 23 of 27

Anonymous
Not applicable

Cool. So do I just load this lisp and I should be able to type "f___" and get a fillet with "___" radius and so forth?

0 Likes
Message 24 of 27

Anonymous
Not applicable

Oh great it is working. It didn't work at first, not sure what happened, but I tried it again just now and it was working.

I like it. So I do have a question, what would need to be changed if I use a different shortcut/alias for one of those. I use "F" for fillet, but I use "C" for copy and "CV" for circle, and I use "SE" for offset instead of "O". I try to keep all my commands around the 1 to 5, Q to T, A to G, and Z to B keys.

 

Thanks,

Michael

0 Likes
Message 25 of 27

Sea-Haven
Mentor
Mentor

As this checks for errors your shorthands should work and not conflict. I only look at 1st character. You could use a different letter.

 

Was there a problem with it working ?

0 Likes
Message 26 of 27

Anonymous
Not applicable

Ah! I see, even though I use "CV" as shorthand for the circle, "C___" works for a circle and so on. For the example of "O___" for offset command, how would I change to "S___"? I like the be super lazy and not reach all the way over to the middle side of the keyboard for shorthand, hah!

 

I tried this, but it didn't work for me:

(  (and
            (wcmatch com "~*[~S.0-9]*")   ;;; changed "O" to "S"
            (wcmatch com "S*")                 ;;; changed "O" to "S"
            (wcmatch com "~S*S*")           ;;; changed "O" to "S"
            (wcmatch com "~*.*.*")
            ) ; and
            (offdist) 
         )

I figured this would be the fix, but it doesn't seem to work, but maybe I'm missing something.

 

*EDIT: So this did work... I'm not sure why but it wasn't working at first! So I can enter "S20" and get an offset of 20.*

 

Thanks!

Michael

0 Likes
Message 27 of 27

Sea-Haven
Mentor
Mentor

Good to here don't forget to use -for decimal.

 

Basicly you can have 26 options A-Z, I had open dwg as an option as all our dwgs use a project number and a set directory structure. 

0 Likes