On 30/04/2013 at 04:23, xxxxxxxx wrote:
Hi Alex,
Scene modifications should not be done from a script. So while your script runs, you will not
be able to do any further modifications to the scene.
While your script is running, you can frequently check if the script should be stopped, and then,
just stop. This can be achieved in several ways. Two ideas:
1. Listen for a key to be pressed
This is usually the escape key on the keyboard. You can check if the escape key is pressed
like so
import c4d
from c4d.gui import GetInputState
def escape_pressed() :
bc = c4d.BaseContainer()
rs = GetInputState(c4d.BFM_INPUT_KEYBOARD, c4d.KEY_ESC, bc)
if rs and bc[c4d.BFM_INPUT_VALUE]:
return True
return False
Make sure to frequently check for for the escape key. If you only check about each second, you
can easily miss a short press on the key.
2. Accept the break message over network
You can open a socket and recieve a break "command" over the network. This would allow you
to stop the script from anywhere in your local network (or even from the outside when the
required ports etc. are set up). This approach may be a little to overkill for what you are aiming for.
Best,
-Niklas