How to get consisten frame format with $FF

   1865   6   0
User Avatar
Member
19 posts
Joined: Nov. 2018
Offline
Hello,

I'm doing some exporting caches with subframe turned on.

I noticed that if, for example, I have a substep of 4, and I name my file something like `name.$FF.vdb` the caches will have the following names:

`name.1.vdb`
`name.1.25.vdb`
`name.1.5.vdb`
`name.1.75.vdb`
`name.2.vdb`

and so on.

I need those name to have a consistent format for the frame, ideally I'd like the output to be this:

`name.1.00.vdb`
`name.1.25.vdb`
`name.1.50.vdb`
`name.1.75.vdb`
`name.2.00.vdb`

In particular having always the same amount of “.” in the name is necessary.


I could fix this using a post-frame script, but that seems like overkill and would also be I/O intensive.


Is there any way to obtain that result through parameter expressions, or setting some config files, or anything like that?


Thanks to anybody who will reply!
User Avatar
Member
2534 posts
Joined: June 2008
Offline
Have you tried embedding the hscript padzero function into your filename? You need to surround it with back ticks for it to take affect.

`padzero(4,$FF)`

$HIP/sim/$HIPNAME.`opname("..")`.`padzero(4,$FF)`.sim
Edited by Enivob - Nov. 18, 2020 09:19:04
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
19 posts
Joined: Nov. 2018
Offline
Thanks for the answer Enivob.
I tried using `padezero` like you suggested but:
  1. for some reason, instead of doing subframes, it went back to export full frames, so I the files became
    `name.0001.vdb`
    `name.0002.vdb`
    `name.0003.vdb`
    etc
  2. even if it worked as expected, padzero adds zero at the beginning of the value passed in it, so the filenames would become
    `name.0001.vdb`
    `name.01.25.vdb`
    `name.001.5.vdb`
    `name.01.75.vdb`
    `name.0002.vdb`

what I need is for the frame number to be represented always in the same way, something like:
1.00 (instead of 1), 1.25 , 1.50 (instead of 1.5) and so on.
Edited by stefa-no - Nov. 18, 2020 10:08:36
User Avatar
Member
19 posts
Joined: Nov. 2018
Offline
I was able to build an expression that works for me:
name.`padzero(4, substr($FF, 0, strlen($F)))`.`padzero(4,0+substr($FF, strlen($F)+1, 4))`.vdb


this gives me files with the following format:
`name.0001.0000.vdb`
`name.0001.0025.vdb`
`name.0001.0050.vdb`
`name.0001.0075.vdb`
`name.0002.0000.vdb`
etc.

An interesting caviat was that in
padzero(4,0+substr($FF, strlen($F)+1, 4))
I had to do the `0+` because otherwise when there was no subframe number(like in full frames, which are represented as integers by $FF) `padzero` didn't work.



Anyway, problem solved!
Edited by stefa-no - Nov. 18, 2020 11:05:18
User Avatar
Member
19 posts
Joined: Nov. 2018
Offline
I do have a new question now:
The expression above works perfectly, if I set a file to have
name.`padzero(4, substr($FF, 0, strlen($F)))`.`padzero(4,0+substr($FF, strlen($F)+1, 4))`.vdb
as name, it will export all of the subframes of the frame-range as expected.

That frame expression is very ugly though, so I though to put it in a global variable to make it more usable, so I went to the HScript textport and run
setenv SUBF = `padzero(4, substr($FF, 0, strlen($F)))`.`padzero(4,0+substr($FF, strlen($F)+1, 4))`

Doing this though, it seems like the expression gets evaluated at global variable creation time, rather than when it is used. So
if I then try to do
echo $SUBF
I always get the same frame (i.e. the one I was in when I created the variable), independently from my current frame.

Is there a way to defer the expression evaluation to when the global variable itself gets evaluated?
User Avatar
Member
8539 posts
Joined: July 2007
Online
stefa-no
Is there a way to defer the expression evaluation to when the global variable itself gets evaluated?
instead of using variable, you can define your custom expression functions in Edit/Aliases and Variables…/Expressions
and then use that expression in your string instead

while custom expression functions can simplify stuff I personally avoid custom expressions as they have to live in your houdini session so copy/pasting the node to different session that doesn't have the expression defined will break things

you can alternatively try using python and whle not the shortest it may be more tolerable
name.`pythonexprs("'%07.2f' % hou.frame()")`.vdb
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
19 posts
Joined: Nov. 2018
Offline
Thanks you a lot for your answer tamte!

After struggling a bit with the syntax, I was finally able to implement your suggestion.

I created a file called `custom_expressions.expr` inside which I put my custom expression:
string SF(){
    return strcat(strcat(padzero(4, substr($FF, 0, strlen($F))), "."), padzero(4,0+substr($FF, strlen($F)+1, 4)));
}

Then, in the `456.py` file, I added this:
hou.hscript("exread /path/to/custom_expressions.expr")


With this setup, I now can write my filenames like so:
name.`SF()`.vdb

And I get exactly the filenames expected.

Thanks!
Edited by stefa-no - Nov. 20, 2020 10:27:23
  • Quick Links