Jump to content

automatically creating directory when it doesn't exist at renderti


pclaes

Recommended Posts

Hi,

I was wondering if it is possible to use a pre-render script in a mantra node that checks if the path for the output file exists and if not, create the directories required for that path.

I am trying to automate as much parts of the rendering workflow as I can by using some global variables in my output paths for versioning and also using $ACTIVETAKE to include the current take in the path for different renderlayers.

What I would like to create is a little script (probably) in the pre-render script field that generates those directories if they do not exist.

The logic of this is not that difficult, but I do not really know where to start. Should I write something like this in python, does python from within houdini have access to those kind of commands to create new directories? Or should I use a different scripting language? ( I've recently come across some tcl scripts when figuring out some things in Nuke, perhaps this works with Houdini? )

Where would the script be stored? On disk or in the hip file itself?

Thank you for any advice (or even pointing to other resources) you could give me on this subject.

Link to comment
Share on other sites

Ouch! There are some guys around that have their good believes about it why ROP drivers shouldn't create any directory on disk...

There are also a number of reasons why we should believe them, besides this clearly practical temptation of doing such nasty things.

1. Yes, Python has a fully access to all modules like os, os.path that handle duties like creating directories. More over hscript itself has a bunch of related routines like: umkdir, urm, uls etc.

2. The options for placing scripts start from $HOME/houdinix.x/scripts/python/ to Mantra driver definition that can be customized (effectively you can have your own Mantra driver).

What I did for that very purpose is a custom Manager (called HARM), thats handles all duties onces pointed to one of Mantra ROP. So the ROP stays the same (easier to manage renders in GUI and portability), but HARM HDA checks all paths in it, creates deepraster plates based on job profile if needed, modifies paths based on takes, versions found on disk etc. In MantraROP output there is always one expression like (for example):

$SERVER/$JOB/$RENDER/${OS}__VERSION__$ACTIVETAKE.$F4.exr

and I'm not touching it. Never. All variables depends on job or are modified (like __VERSION__) by HARM per every render.

There are so many ways to go here.

hth,

sy.

Link to comment
Share on other sites

Thank you Mario for your help.

The command itself did not work as I am under windows at the moment, but I switch between windows and linux.

However I started digging around in the help file based on your command and found the following:

Call host system commands

Use the ucd and unix commands to start the language

Link to comment
Share on other sites

Ouch! There are some guys around that have their good believes about it why ROP drivers shouldn't create any directory on disk...

There are also a number of reasons why we should believe them, besides this clearly practical temptation of doing such nasty things.

1. Yes, Python has a fully access to all modules like os, os.path that handle duties like creating directories. More over hscript itself has a bunch of related routines like: umkdir, urm, uls etc.

2. The options for placing scripts start from $HOME/houdinix.x/scripts/python/ to Mantra driver definition that can be customized (effectively you can have your own Mantra driver).

What I did for that very purpose is a custom Manager (called HARM), thats handles all duties onces pointed to one of Mantra ROP. So the ROP stays the same (easier to manage renders in GUI and portability), but HARM HDA checks all paths in it, creates deepraster plates based on job profile if needed, modifies paths based on takes, versions found on disk etc. In MantraROP output there is always one expression like (for example):

$SERVER/$JOB/$RENDER/${OS}__VERSION__$ACTIVETAKE.$F4.exr

and I'm not touching it. Never. All variables depends on job or are modified (like __VERSION__) by HARM per every render.

There are so many ways to go here.

hth,

sy.

Thanks for the umkdir command. I can see where creating directories on disk can get a little risky when working in big teams. You want a unified directory structure, could you elaborate a little bit on the custom Manager you created? Wat did you write it in? Did it take you a long time to create it? It sounds quite useful, and that's a pretty big expression for the paths. I noticed you put exr as the extension. Does this imply outputting several information channels/passes into one file rather than splitting it out in different directories? (Or does $RENDER represent the current pass?)

Thanks also for letting me know about the location of the scripts, this will come in handy a lot.

Link to comment
Share on other sites

Ouch! There are some guys around that have their good believes about it why ROP drivers shouldn't create any directory on disk...

There are also a number of reasons why we should believe them, besides this clearly practical temptation of doing such nasty things.

Oh, crap! I pissed off the sysadmin! <hides>

:lol:

Agreed!

uhmm.. Sir!

So, Private Pclaes! Yeah, you! Listen to me, and listen good! Now that I've given you the unholy power to destroy hours of your own work, not to mention other God-Fearing people's work, and possibly even accidentally blow your own nuts off... (wipe that smile off your face, boy!)... I beg you -- WE'RE *ALL* BEGGING YOU -- to pleeeeease use it wisely!... goddammit!

Sorry, I couldn't resist :P

Yes, you're right Simon, of course. And no, we don't set up our ROPs that way either. And neither should you, pclaes.

(though I *have* on occasion been known to do a quickie COP ROP that way, but just a teeny tiny one, you know "the clients are coming and there's no time" kind of thing. very very small. inoffensive, really... nothing truly dangerous or anything... no damage... ... .. nuts still there... ... phew).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...