MiGo Posted April 13, 2009 Share Posted April 13, 2009 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 13, 2009 Share Posted April 13, 2009 You could use some VL error trapping: (if (not (vl-catch-all-error-p (vl-catch-all-apply <function> <list> ) ) ) ) If its applicable Quote Link to comment Share on other sites More sharing options...
MiGo Posted April 13, 2009 Author Share Posted April 13, 2009 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 13, 2009 Share Posted April 13, 2009 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 Lee Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.