Jump to content

Execute the command based on user input.


acad1985

Recommended Posts

Hello Everyone.

Actually i have lisp file with 5 commands (Command name :1,2,3,4,5)

Please help me to crate lisp for below.

I want call the command by user input.

If i enter 1, command 1should be executed...if i click 2 then command 2 should be executed.

We can directly exeute the commands but I'm trying to call these commands with one macro button.

Please help me anyone.

Link to comment
Share on other sites

Dont see much speed improvement over having a routine maybe  a DCL with buttons over press 1 <Enter>  we use menus and tool bars easy to have a tool bar with 1 2 3 4 5 etc. You will need to make the icons here is the tool bar code. Its a MNU file use menuload. It should work without the icons.

 

***MENUGROUP=NUMBSTOOLBAR
***TOOLBARS
**NumberTOOLS
ID_ALAN_1    [_Toolbar("Alans2", _LEFT, _Show, 50,50, 1)]
1        [_Button("1","1.bmp,"1.bmp")]^c^c^c(command "1")
2        [_Button("2","2.BMP","2.BMP")]^c^c^c(command "2")

 

 

 

 

  • Like 1
Link to comment
Share on other sites

Hello BIGAL,

Thanks for your reply.

Actually i'm not aware of this *.mnu files, but i have load using MENULOAD as you mentioned.

after that i'm checking in there is no Toolbar is available. i have checked on Menubar->Tools->Toolbar  NUMBSTOOLBAR is available there. but when i select Alans2 on that toolbar, nothing is appear in Autocad . Could you please help me on this.

 

Link to comment
Share on other sites

(initget "1 2 3 4 5")
(setq OP (getkword " [1/2/3/4/5]: "))

You could modify the lisp.  Allows you to enter an option, pick it on the command line, or pick it on the screen.  Of course using descriptive command names would be easier for your users to understand while still being able to start one with a single click or entering a single letter.  Still just using that one macro button.

Link to comment
Share on other sites

Nice one Grr

 

Acad1985 will find out why its not working not sure at this point just cut and pasted another toolbar.

 

Grr I have c123 f45 o34 Circle with radius xxx, fillet with radius xx, offset etc reads the xxx bit of the unknown command posted a couple of times here. ps it has more options.

Edited by BIGAL
Link to comment
Share on other sites

5 hours ago, BIGAL said:

Grr I have c123 f45 o34 Circle with radius xxx, fillet with radius xx, offset etc reads the xxx bit of the unknown command posted a couple of times here. ps it has more options.

 

I've seen that reactor program, BIGAL. And I find it awesome!

Link to comment
Share on other sites

Hello Experts,

Thank you so much for your time.

Tombu, I tried your code,  its shows unknown command what i entered the value.

(defun c:asd()
(initget "1 2 3 4 5")
(setq OP (getkword " [1/2/3/4/5]: "))
)

Grrr and BIGAL I've seen your Post.  Your code is Nice and awesome. but this code for Assign a Shortcut for Commands. actually i have lisp for multiple offset.. using this we will offset 4 lines at a time. but some time we need to offset 2,3,5 and 6 lines. so i have copy the lisp with different command (1,2,3,4,5,6 like that). so that's why i'm asking to call these all the commands with single command.

 

Thanks for understanding.:cute:

Link to comment
Share on other sites

Okay, heres one suggestion:

(defun C:asd ( / L n itm )
  (and
    (setq L 
      '(nil ; Write down your commands here :
        "CIRCLE"
        "LINE"
        "PLINE"
        "TEST" ; <- example for a custom LISP command 
      ); list
    ); setq L
    (setq n (progn (initget 6) (getint (strcat "\nSpecify number of the command (max " (itoa (1- (length L))) ") <exit>: "))))
    (setq itm (nth n L))
    (vla-SendCommand (vla-get-ActiveDocument (vlax-get-acad-object)) (strcat itm "\r"))
  ); and
  (princ)
); defun 
(vl-load-com) (princ)


(defun C:test ( / ) ; <- example for a custom LISP command defining
  (alert "\nThis is my other routine, it does awesome stuff.")
  (princ)
); defun 

 

Link to comment
Share on other sites

nice Grrr! maybe add a little user feedback


....

);setq L

(setq i 0)
  (princ
    (strcat "\n"
        (apply 'strcat
            (mapcar '(lambda (x)(strcat "(" (itoa (setq i (1+ i))) ") " x " "))
                (cdr L))))
  )

(setq n...

...

of course only usefull when not having too many commands in the list 🤗

Link to comment
Share on other sites

6 minutes ago, acad1985 said:

Hey Grrr

Thank you so much 

This is awesome , it's working what i want 

Thank you so much rlx and Grrr:celebrate:

 

your welcome but 99.99% of the credits goes to Grrr!  👍 Think I would have used Grrr-read instead of initget (so I wouldn't have to use enter) but that would give longer code and be practical for no more than 9 or 10 commands. 🍻 in the end , only thing that counts is you being happy. So well done Grrr !

Link to comment
Share on other sites

My version of multi offset uses a csv approach so can have as many offsets as you like, -ve numbers will go in opposite direction. Its at home so can not post now will see if I can find here. it asks for user input so no hard coding offset -> 1,34,23.45,-12,-25 etc. 

 

 

 

 

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