Jump to content

Scrip question for toggling through viewports


Recommended Posts

Posted

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?

  • Replies 34
  • Created
  • Last Reply

Top Posters In This Topic

  • MiGo

    17

  • Lee Mac

    15

  • NBC

    2

  • Organic

    1

Top Posters In This Topic

Posted

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.

Posted

Why not just close the drawing, instead of AutoCAD itself ?

Posted

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.

Posted

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"))
 )

Posted

Take a read of this, some good info on progn here:

http://www.cadtutor.net/forum/showpost.php?p=173196&postcount=10

Posted

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"))

)

Posted

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")
 )

Posted

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.

Posted

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.

Posted

It works, i'm just working on other bugs now but that's just an extra space here or there.

Posted

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.

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