Page 1 of 1

Startup scripts

Posted: Tue Jun 04, 2013 11:16 pm
by Otuama
Is it possible to run custom python scripts at startup?

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 :x 8hrs in A&E :o )

Re: Startup scripts

Posted: Thu Jun 06, 2013 9:04 am
by Alex
Hi Sean,

Just place a script called "startup.rfs" in your RealFlow installation directory. I just tested it and seems to work.

Plus we'll keep in mind those two missing functions.

Re: Startup scripts

Posted: Thu Jun 06, 2013 9:18 am
by Otuama
That works. Nice.

Re: Startup scripts

Posted: Thu Jun 06, 2013 9:38 am
by Otuama
In the future, maybe add the turning on/off of the grid & camera frame in the global prefs. There isn't much point there being a script for it but it would be good to have the option to have them turned off whenever Rf starts.

--------------

Also, something which may be quite good is the ability to script the creation of simulation events. Something like what Maya can do where a batch script creates a runtime expression. Trying to think of an example why this can be used..... but can't.

--------------

I had another idea which I thought was quite good but can't remember it. Hate it when that happens!!

Re: Startup scripts

Posted: Thu Jun 06, 2013 10:08 am
by Alex
Right now, there exists an ugly way of adding new scripts to the Simulation Events.

However, it's ugly (again), and I think it only works by adding the scripts (or graph or plugin). If I recall correctly you cannot access the existing ones.
This way is through the scene XML import feature.

If you want more information just ask and I can try to create some example.

Re: Startup scripts

Posted: Thu Jun 06, 2013 10:11 am
by Otuama
It'd be good to have an example, thanks.

However, only when you have some time and are bored. It's not important right now.

Re: Startup scripts

Posted: Thu Jun 06, 2013 10:33 am
by Alex
I managed to create a working example quite quickly, so here you have:

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 )

Re: Startup scripts

Posted: Fri Jun 07, 2013 4:22 pm
by Otuama
That's damn cool, thanks.

I wonder whether it'd be worth bringing this functionality into Rf.

Re: Startup scripts

Posted: Wed Sep 11, 2013 2:46 pm
by ben.fox@framestore.com
Just still trying to get some more info about startup scripts.
Is having startup.rfs in your realflow install directory the only way to have startup scipts run?
There is no more pipeline friendly way of doing this?
The software install part of our pipeline is off limits. All software scripts and plugins reside in a separate version controlled part of the pipeline to keep things clean.
Surely there must be a way of doing this.
Please, if anyone has any info I would be really appreciative.
Thanks.
~Ben