Accessing Export Central Variables through a batch Script

Discussion about scripting with Python
mdonovan
Posts: 121
Joined: Wed Jun 17, 2009 3:59 pm

Accessing Export Central Variables through a batch Script

Postby mdonovan » Wed Jun 17, 2009 4:01 pm

Hi ... super new to python in Realflow ...

Is there a way to access export central through scripting. I want to be able to grab the SCENEDIR variable and change it.

Thanks


lukeiamyourfather
Posts: 2880
Joined: Mon Oct 15, 2007 4:09 pm
Contact:

Accessing Export Central Variables through a batch Script

Postby lukeiamyourfather » Wed Jun 17, 2009 5:07 pm

Welcome to the forum! There's no class (or module) specifically for Export Central, but rather the export paths and names are changed through the class for each object, emitter, etc. For example these are in the emitter class, shown in the scripting reference section of the help.

string getExportResourcePath( int )

Get the emitter's path for a specific exported resource. Valids resources are EXPORT_PARTICLES_BIN, EXPORT_PARTICLES_ASC and EXPORT_PARTICLES_PDC.
Arguments
(1) Emitter's resource Id.
Return
Emitter's resource's path. None if the resource is not found.



setExportResourcePath( int, string )

Set the emitter's path for a specific exported resource. Valids resources are EXPORT_PARTICLES_BIN, EXPORT_PARTICLES_ASC and EXPORT_PARTICLES_PDC.
Arguments
(1) Emitter's resource Id.
(2) Path.
Return
None.



string getExportResourceName()

Get the emitter's exported resource name. This is the name used for the root of the file name exported for all resources in this emitter.
Arguments
None.
Return
Emitter's resource's name.



setExportResourceName( string )

Set the emitter's name for a specific exported resource.
Arguments
(2) Emitter's resource's name.
Return
None.



bool isExportResourceActive( int )( string )

Get the Emitter's active state for a specific exported resource. Valids resources are EXPORT_PARTICLES_BIN, EXPORT_PARTICLES_ASC and EXPORT_PARTICLES_PDC.
Arguments
(1) Emitter's resource Id.
Return
True if the specific resource is active for exporting or False otherwise. None if the resource is not found.



activeExportResource( int, bool )

Set the Emitter's active state for a specific exported resource. Valids resources are EXPORT_PARTICLES_BIN, EXPORT_PARTICLES_ASC and EXPORT_PARTICLES_PDC.
Arguments
(1) Emitter's resource Id.
(2) True to active the resource for exporting, False otherwise.
Return
None.

Using those you can change things to export to anywhere. Maybe not as easy as changing just one global variable but it works. Cheers!

mdonovan
Posts: 121
Joined: Wed Jun 17, 2009 3:59 pm

Accessing Export Central Variables through a batch Script

Postby mdonovan » Wed Jun 17, 2009 5:29 pm

i don't understand where the SCENEDIR variable gets assigned ... is it unchangeable from the moment you create a project ? what if you copy the .flw to a new location ?

thanks for the response though it was very helpful.

so I am a little confused ... when you change the values on the object does it actually change the path in export central ? So next time I open it up it will be altered ? Also ... how do I get the objects "Resource ID". It looks like function such as getExportResourcePath require some integer id.

lukeiamyourfather
Posts: 2880
Joined: Mon Oct 15, 2007 4:09 pm
Contact:

Accessing Export Central Variables through a batch Script

Postby lukeiamyourfather » Wed Jun 17, 2009 5:55 pm

mdonovan wrote: i don't understand where the SCENEDIR variable gets assigned ... is it unchangeable from the moment you create a project ? what if you copy the .flw to a new location ?

Its dynamic and probably gets assigned when the file is opened. At first I didn't know what you were talking about until I opened Export Central and saw it in the paths. Why do you want to change it anyway? Cheers!

mdonovan
Posts: 121
Joined: Wed Jun 17, 2009 3:59 pm

Accessing Export Central Variables through a batch Script

Postby mdonovan » Wed Jun 17, 2009 6:01 pm

I am writing various workflow scripts for our studio and we have multiple command line licenses. We discovered that simulating locally on the machines was much faster than from a shared network drive. I wanted to be able to pop a dialogue box to change where the particles/meshes are written to and read from etc. So I dont have to go in and change each output path by hand.

the script below actually gets the OBJECT export path. Not the SCENEDIR. literally it returns $(SCENEDIR)/objects.

sc = scene.getExportResourcePath(1)
if ( sc == None ):
scene.message( "path not found.")
else:
scene.message( sc )

I am just trying to wrap my head around all this stuff.

How do I retrieve and objects resource_id ???

lukeiamyourfather
Posts: 2880
Joined: Mon Oct 15, 2007 4:09 pm
Contact:

Accessing Export Central Variables through a batch Script

Postby lukeiamyourfather » Wed Jun 17, 2009 6:15 pm

That might not be the best idea. I understand wanting to reduce the latency and bandwidth limitations of the network, but it would be best to keep the project self contained instead of keeping the scene on the network and the BIN files local. In other words you're going about it in a more complicated fashion than it really needs to be and that'll probably cause more issues in the long run than just copying the whole project local.

To solve the same problem I wrote a few shell scripts to copy a project to a local scenes directory, and then put it back on the network drive where it came from when I'm done, the whole project directory. For simulation nodes it could be done with an external Python script that first copies the specified scene, then simulates, then copies everything back. Cheers!

mdonovan
Posts: 121
Joined: Wed Jun 17, 2009 3:59 pm

Accessing Export Central Variables through a batch Script

Postby mdonovan » Wed Jun 17, 2009 6:15 pm

i did figure out that the resource_id is equal the the hiearchy of the export_central tree. So EMMITERS has a resource ID of 1 under the scene object, and Particle Cache would be an id of 1 under an emitter.

I need to figure out what function returns an array of objects from the scene and be able to filter the array by object type.

mdonovan
Posts: 121
Joined: Wed Jun 17, 2009 3:59 pm

Accessing Export Central Variables through a batch Script

Postby mdonovan » Wed Jun 17, 2009 6:20 pm

your solution makes some good sense ... I guess in a windows environment I would just write a DOS batch script ?? ...

something like

xcopy /s %1 %2
cd %2
realflownode exampl.flw
copy /s %2 %1

??

Is there a better way ? maybe that would allow some sort of gui ?

lukeiamyourfather
Posts: 2880
Joined: Mon Oct 15, 2007 4:09 pm
Contact:

Accessing Export Central Variables through a batch Script

Postby lukeiamyourfather » Wed Jun 17, 2009 6:27 pm

mdonovan wrote: your solution makes some good sense ... I guess in a windows environment I would just write a DOS batch script ?? ...

something like

xcopy /s %1 %2
cd %2
realflownode exampl.flw
copy /s %2 %1

??

Is there a better way ? maybe that would allow some sort of gui ?

Essentially yes, that's the idea. If its just one artist working on the shot then they can copy it local for a few weeks if needed, and just update the network storage with a new version when needed using an icon on their desktop that runs a script. For simulation nodes the batch or shell script works just fine and doesn't need a GUI to run. The whole sequence of simulating on a node could be initiated in RealFlow with a GUI though, a batch script. However you do it try to keep projects self contained and not split up assets from the scene file. Cheers!

mdonovan
Posts: 121
Joined: Wed Jun 17, 2009 3:59 pm

Accessing Export Central Variables through a batch Script

Postby mdonovan » Wed Jun 17, 2009 6:31 pm

lukeiamyourfather wrote: The whole sequence of simulating on a node could be initiated in RealFlow with a GUI though, a batch script. However you do it try to keep projects self contained and not split up assets from the scene file. Cheers!

Sorry if this is obvious ... but how do I do the whole thing from a batch within realflow ... I mean how to I execute the remote command line from within my local realflow ?

man I fell like a noob.


Return to “Python-Scripting”

Who is online

Users browsing this forum: No registered users and 2 guests