Startup scripts

Post Reply
User avatar
Otuama
Posts: 162
Joined: Sun Jun 27, 2010 2:29 pm

Startup scripts

Post by Otuama » Tue Jun 04, 2013 11:16 pm

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 )
Otuama - Vimeo
'Strength does not come from physical capacity. It comes from an indomitable will.' - Gandhi

User avatar
Alex
Site Admin
Posts: 143
Joined: Mon Jun 14, 2010 9:35 am

Re: Startup scripts

Post by Alex » Thu Jun 06, 2013 9:04 am

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.
Alex Ribao
RealFlow Team
Next Limit Technologies

User avatar
Otuama
Posts: 162
Joined: Sun Jun 27, 2010 2:29 pm

Re: Startup scripts

Post by Otuama » Thu Jun 06, 2013 9:18 am

That works. Nice.
Otuama - Vimeo
'Strength does not come from physical capacity. It comes from an indomitable will.' - Gandhi

User avatar
Otuama
Posts: 162
Joined: Sun Jun 27, 2010 2:29 pm

Re: Startup scripts

Post by Otuama » Thu Jun 06, 2013 9:38 am

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!!
Otuama - Vimeo
'Strength does not come from physical capacity. It comes from an indomitable will.' - Gandhi

User avatar
Alex
Site Admin
Posts: 143
Joined: Mon Jun 14, 2010 9:35 am

Re: Startup scripts

Post by Alex » Thu Jun 06, 2013 10:08 am

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.
Alex Ribao
RealFlow Team
Next Limit Technologies

User avatar
Otuama
Posts: 162
Joined: Sun Jun 27, 2010 2:29 pm

Re: Startup scripts

Post by Otuama » Thu Jun 06, 2013 10:11 am

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.
Otuama - Vimeo
'Strength does not come from physical capacity. It comes from an indomitable will.' - Gandhi

User avatar
Alex
Site Admin
Posts: 143
Joined: Mon Jun 14, 2010 9:35 am

Re: Startup scripts

Post by Alex » Thu Jun 06, 2013 10:33 am

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 )
Alex Ribao
RealFlow Team
Next Limit Technologies

User avatar
Otuama
Posts: 162
Joined: Sun Jun 27, 2010 2:29 pm

Re: Startup scripts

Post by Otuama » Fri Jun 07, 2013 4:22 pm

That's damn cool, thanks.

I wonder whether it'd be worth bringing this functionality into Rf.
Otuama - Vimeo
'Strength does not come from physical capacity. It comes from an indomitable will.' - Gandhi

ben.fox@framestore.com
Posts: 41
Joined: Thu Aug 29, 2013 4:12 pm

Re: Startup scripts

Post by ben.fox@framestore.com » Wed Sep 11, 2013 2:46 pm

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

Post Reply