Jump to content

Script Question


MiGo

Recommended Posts

Is there a way to determine if the last command returned an error, and put that in an if statement? I have come across drawings where someone had turned off a viewport and forgotten about it due to the fact that it matched the color and shape of the title border. So when I use a script to enter a viewport sometimes I get an error because the viewport is off, and then the script runs on the previous viewport again.

 

(if (error logic)

(princ

Do stuff here...

)

)

 

So if the viewport is off then I can move onto the next one correctly. The other problem with this is if the viewport is off it doesn't get accounted for in the (length (vports)) that I use so this would allow for me to account for this.

Link to comment
Share on other sites

Nevermind I found another way of accomplishing my goal

 

mspace

(setvar "cvport" vpc)

(if (> vpc (getvar "cvport"))

(setq vpc (1+ vpc))

)

(if (> vpc (getvar "cvport"))

(command "rscript")

)

 

Having the mspace at the top will return a message of already in modelspace, but not error out. So the extra space after this sub section will just return that message until the next viewport is accepted by cad skipping the if statements and just doing another mspace.

 

Lee I have posted the script in this AutoCAD General section if you wanted to check it out.

Link to comment
Share on other sites

Nevermind I found another way of accomplishing my goal

 

mspace

(setvar "cvport" vpc)

(if (> vpc (getvar "cvport"))

(setq vpc (1+ vpc))

)

(if (> vpc (getvar "cvport"))

(command "rscript")

)

 

Having the mspace at the top will return a message of already in modelspace, but not error out. So the extra space after this sub section will just return that message until the next viewport is accepted by cad skipping the if statements and just doing another mspace.

 

Lee I have posted the script in this AutoCAD General section if you wanted to check it out.

 

 

Glad you got it sorted MiGo, I shall check it out :thumbsup:

 

Lee

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