MiGo Posted March 26, 2009 Author Posted March 26, 2009 So should this work? (if (eq (length (vports)) 1) (command "tilemode" "0") (command "copybase" "0,0,0" "c" "-20,-20" "120,120" "") (command "model") (command "erase" "all" "") (command "pasteclip" "0,0,0") (command "purge" "all" "" "n") (command "purge" "all" "" "n") (command "purge" "all" "" "n") (command "audit" "y") (command "qsave") (command "exit") ) Not sure about the "progn" does it go after the last command line as (progn) kinda like the (princ)? Also in substitue to the exit is there a command to end the script if exit won't just end it? Quote
MiGo Posted March 26, 2009 Author Posted March 26, 2009 Yes that is the desired effect. Script pro unfortunatly opens autocad and closes it for every drawing, so if I can interrupt the script by exiting then script pro will continue to the next drawing on the list. Quote
NBC Posted March 26, 2009 Posted March 26, 2009 Why not just close the drawing, instead of AutoCAD itself ? Quote
MiGo Posted March 26, 2009 Author Posted March 26, 2009 Script pro is a program that runs a script on all designated drawings. The program exits anyway. What I am after is interrupting the script if the IF statement is true after doing what you saw. There is more to the script after this point, but I just want to end it If true. I tried running the script with this in it, and I still got a syntax error when trying. (if (eq (length (vports)) 1) (command "tilemode" "0") (command "copybase" "0,0,0" "w" "-20,-20" "120,120" "") (command "erase" "all" "") (command "model") (command "erase" "all" "") (command "pasteclip" "0,0,0") (command "purge" "all" "" "n") (command "purge" "all" "" "n") (command "purge" "all" "" "n") (command "audit" "y") (command "qsave") (command "exit") ) I also added the (progn) after the last command line to see if that was the problem and I got the same result. Quote
Lee Mac Posted March 26, 2009 Posted March 26, 2009 I haven't touched the "exit" problem, but this wil solve your issue with progn: (if (eq (length (vports)) 1) (progn (command "tilemode" "0") (command "copybase" "0,0,0" "w" "-20,-20" "120,120" "") (command "erase" "all" "") (command "model") (command "erase" "all" "") (command "pasteclip" "0,0,0") (command "purge" "all" "" "n") (command "purge" "all" "" "n") (command "purge" "all" "" "n") (command "audit" "y") (command "qsave") (command "exit")) ) Quote
Lee Mac Posted March 26, 2009 Posted March 26, 2009 Take a read of this, some good info on progn here: http://www.cadtutor.net/forum/showpost.php?p=173196&postcount=10 Quote
MiGo Posted March 26, 2009 Author Posted March 26, 2009 Ok got an issue. I test ran the script on a drawing with two viewports and the If statement returned a nill and continued running through the whole drawing. here was the section of the If statement that should have ended the script. (if (eq (length (vports)) 3) (progn (command "tilemode" "0") (c:mycommand) (command "zoom" "e") (command "copybase" "0,0,0" "w" "-20,-20" "120,120" "") (command "laythw") (command "layon") (command "zoom" "e") (command "erase" "all" "") (command "model") (command "erase" "all" "") (command "pasteclip" "0,0,0") (command "zoom" "e") (command "purge" "all" "" "n") (command "purge" "all" "" "n") (command "purge" "all" "" "n") (command "audit" "y") (command "qsave") (command "quit" "y")) ) Quote
Lee Mac Posted March 26, 2009 Posted March 26, 2009 Not sure exactly of the problem, but have put the "quit" command outside of the progn statement: (if (eq (length (vports)) 3) (progn (command "tilemode" "0") (c:corningprep) (command "zoom" "e") (command "copybase" "0,0,0" "w" "-20,-20" "120,120" "") (command "laythw") (command "layon") (command "zoom" "e") (command "erase" "all" "") (command "model") (command "erase" "all" "") (command "pasteclip" "0,0,0") (command "zoom" "e") (command "purge" "all" "" "n") (command "purge" "all" "" "n") (command "purge" "all" "" "n") (command "audit" "y") (command "qsave")) (command "quit" "y") ) Quote
MiGo Posted March 26, 2009 Author Posted March 26, 2009 This is what my text windo for the command prompt returned when the script was running like this Command: (if (eq (length (vports)) 3) (_> (progn ((_> (command "tilemode" "0") ((_> (c:corningprep) ((_> (command "zoom" "e") ((_> (command "copybase" "0,0,0" "w" "-20,-20" "120,120" "") ((_> (command "laythw") ((_> (command "layon") ((_> (command "zoom" "e") ((_> (command "erase" "all" "") ((_> (command "model") ((_> (command "erase" "all" "") ((_> (command "pasteclip" "0,0,0") ((_> (command "zoom" "e") ((_> (command "purge" "all" "" "n") ((_> (command "purge" "all" "" "n") ((_> (command "purge" "all" "" "n") ((_> (command "audit" "y") ((_> (command "qsave")) (_> ) nil If i have the (command "quit" "y") outside the progn it automatically does it for the if statement because of the statement being false. but when in the same drawing i type (length (vports)) it returns like this Command: Regenerating layout. Regenerating model. Command: (length (vports)) 3 So I don't know why it isn't working but it's not. Quote
MiGo Posted March 26, 2009 Author Posted March 26, 2009 I think I got it. I wasn't returning to paperspace before running the if statement so the value returned was only the # of layout tabs i think. or just always 1 for the view of model space. I am fixing it now will let you know the result. Quote
MiGo Posted March 26, 2009 Author Posted March 26, 2009 It works, i'm just working on other bugs now but that's just an extra space here or there. Quote
MiGo Posted March 26, 2009 Author Posted March 26, 2009 Hopefully one last question. how can I add this line into the if statement that I have developed? (setq ss (ssget "((0 . "viewport")))) all I used this line to select all of the viewports in the drawing to erase them after the conversion, but due to the add in of the if statement i'm not sure how to use it. When i put it in as such or with some minor modified " marks it still wants me to select the items after the if statement. Quote
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.