Python scripts can be added to SmartBody that are run at various stages of the simulation. A Python script can access any of SmartBody's internal structures through the Python API. Scripts can be used, for example, to query or trigger certain events on a frame-by-frame basis.
Simple Script Example
class SimpleScript(SBScript):
def start(self):
print "Starting MyScript..."
def stop(self):
print "Stopping MyScript..."
def beforeUpdate(self, time):
print "Before simulation step..."
def afterUpdate(self, time):
print "After simulation step..."
def update(self, time):
print "During simulation step at time " + str(time)
myscript = SimpleScript()
scene.addScript("simple", myscript)
Note that changing the file containing a script will not automatically change the behavior of a script. If a change is made, the script will have to be first removed from the scene:
scene.removeScript("simple")
then added again:
scene.addScript("simple")