Jump to content

command for immediately interrupting a script


Recommended Posts

Hi,

does there exist a command (both in Vectorscript and Python) for immediately interrupt a script in both python and Vectorscript? I actually am using the foreach-command quite often. There it's quite difficult interrupting with a dialogue with an abort button. Unfortunately "Ctrl-C", "Esc"... don't work. the only working alternative actually is forcing Vectorworks to close completely.

Thanks for your help!

  • Like 1
Link to comment
11 hours ago, Pat Stanford said:

if you can't click the cancel button I don't have a lot of hope.

at least there's a task manager/activity manager on any computer for that case ;-). 

 

But, seriously, how can I implement a dialogue with an abort-button in a foreach-loop which cycles through an undefined number of objects?

In a for or while loop I can just use an AlertQuestion which returns me the value for escaping the loop, when I press the abort button. But in a foreach-loop?

Link to comment

Add a line in your loop to check for user input and break out of the loop if you get it. Something like.

 

Repeat

 

Repeat
	Begin
		{Your loop code here}
		B1:=((Keydown=113) & Option);  {B1 = True if Option Q Pressed}
	End;
Until ((Condition that ends your loop) | B1);   

This gives VW an excuse to look for keypresses during the loop and should make it breakable as well as manually quitable.

Link to comment

I can't check right now, but can you force a ForEachObject() routine to both check the keydown and not go on to the next object?  I would think it would go to the next object and check the keydown again.  I don't see a way to drop to the last object that meets the conditions in the criteria and then out of the loop.  I love ForEach...  loops, but I don't see a way to end them early.  Of course, I haven't tried the dreaded "GOTO" statement, but that might work after a button down check in the procedure called by the ForEach call.

Link to comment

MullinRJ writes: 

Quote

You can use GOTO , which causes the execution to jump to the label. GOTO will not jump out of nested procedures, so you'll have to have a and a GOTO at each level to jump to the end of that level when some condition is TRUE.

would mean, that there is no exit but "command-." from a foreach-loop.

However, really good ideas!

https://forum.vectorworks.net/index.php?/topic/44637-abort-script-upon-actionvariable/

Link to comment

Particularly if you're doing some experimentation and testing, you can write in a fail-safe counter to break out of while/do loops:

 

while notFound and safeCount < 10000

    ...

    safeCount += 1

 

That doesn't really help with ForEachObject(), though, as the loop is internal to the command. FEOInLayer and FEOInList do have return, values, however, so you can escape out of them if you counter gets too high.

 

If this is for public consumption, you can do a count before launching the operation and provide a yes/no option to continue.

  • Like 1
Link to comment

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