Jump to content

Run commands in succession


itacad

Recommended Posts

Hello, I would like to know if there is any way to run a series of commands in automatic sequence.

My problem is that I want to automatically run a zoom extension after the conclusion of the command previously launched...

the command in question is part of the commands of an application for autocad and it works by selecting an object...for example like erase command...

I launch erase command, I select an object, I confirm and then I make the zoom.

is it possible? maybe even a series of commands...

Many greetings!

Link to comment
Share on other sites

Use a command reactor:

(vl-load-com)
(or *endcommandreactor*
   (setq *endcommandreactor* (vlr-command-reactor nil '((:vlr-commandended . endcmd))))
)
(defun endcmd (calling-reactor endcmdinfo)
 (and (wcmatch (car endcmdinfo) "ERASE") (vla-zoomextents (vlax-get-acad-object)))
)

Link to comment
Share on other sites

Look into Macro's that's what their for. Else a script or a lisp, but you have to be careful if you stop or error some where. Replace all the input with say,lisp input checking what you have entered is valid then run the command or entmake with all the correct values. Dont do questions inside the "command" answer 1 wrong and it all falls apart. You can daisy chain lisps if you want but I would use a script.

 

A script can be called from a lisp its just another call to a command

 

(defun myy ()
(command "script" "MYYYYSCRIPT")
)

Link to comment
Share on other sites

Thanks to both, unfortunately I'm in trouble with your suggestions

For ronjonp: can you please post a complete lisp? I tried to integrate your piece of code but I create errors...

For BIGAL: I've never used a script, I'd like to learn, can you give me the necessary indications starting from the basics?

Thank you again

Link to comment
Share on other sites

That is complete code? Load it when your drawing opens then try the ERASE command. IMO this is very distracting, but what you asked for.

Link to comment
Share on other sites

Like ronjonp your request is a bit vague. But say erase & zoom extents, copy paste this to command

line and type e3.

(defun C:e3 ( / ss)
(command "erase" (ssget) "")
(command "Zoom" "extents")
) 

Link to comment
Share on other sites

Thank you! It works! I made the following "corrections"

(command "_.erase" (ssget) "")
(command "Zoom" "e")

thank you very much!

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