For example, to turn off the grid and camera safe frame?
Actually, there doesn't seem to be commands for those examples. So, bad examples but the question still stands (even if I can't.... broke my foot yesterday
Code: Select all
""" This is the ugly part """
import os
import tempfile
from xml.sax.saxutils import escape
def _importXml( xmlcode, add=False, update=True, rename=False ):
# Save to temporary file and import
tmp = tempfile.NamedTemporaryFile(suffix=".xml", delete=False)
tmp.write( xmlcode )
tmp.close()
scene.importFromXML( tmp.name, add, update, rename )
os.remove(tmp.name)
def addToSimulationPre( scriptText ):
escapedScript = escape( scriptText )
# Pay attention to the <simulation-pre> tag
xmlPattern = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE rfxml><rfxml version="0.3"><simulation-events>'\
'<simulation-pre><embedded-script active="true" name="Script_embedded_2147483651">%s</embedded-script></simulation-pre>'\
'</simulation-events></rfxml>' % escapedScript
_importXml(xmlPattern,True,True)
""" """
# This is how to use it
myscript = 'scene.message( "hello world" )'
addToSimulationPre( myscript )