How to split @directory in VEXpressions

   1877   6   1
User Avatar
Member
5 posts
Joined: 2月 2022
Offline
Hi, I'm using TOP to batch process some animations.

I'm using File Pattern with Recursive turned on to get all the animations in source folder, and I also want the output to be separated by subfolders.

So I'm trying to use split(@directory, "/") in the ROP_AnimationOutput node. However an error comes with "unable to evaluate expression".

What did I miss/mistake here?
Edited by scareley - 2022年3月17日 01:01:47

Attachments:
houdini-split-directory.png (293.5 KB)

User Avatar
Member
8766 posts
Joined: 7月 2007
Offline
marshall.wang
What did I miss/mistake here?
parameters us Hscript, not VEX and there is no split() function in HScript
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
5 posts
Joined: 2月 2022
Offline
tamte
parameters us Hscript, not VEX and there is no split() function in HScript

Thanks Tomas!

Is there a way to get the @directory string on python side? So that I will be able to use expressions like `pythonexpr("@directory.split('/')"`
User Avatar
Member
8766 posts
Joined: 7月 2007
Offline
you can use this for example
`pythonexprs("pdg.workItem().attribValue('directory').split('/')[-1]")`

however it may be easier to generate PDG attributes in TOPs with subdir names you need and they use simple @subdirname references in your path
you can use Attribute From String TOP for that to either split your @directory attribute into string array attribute by delimiter
or split into separate named attributes based on pattern
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
5 posts
Joined: 2月 2022
Offline
Appreciate it!

Attribute From String [www.sidefx.com] definitely solves the problem.

For those who is also struggling with this:
In my case I simply used {}:/{}/{}/{}/{}/{subfolder}in Simple Pattern.

But yeah for a more complex fold structure, even with various subfolder depth, we will need regex to get what we want
User Avatar
Member
8766 posts
Joined: 7月 2007
Offline
marshall.wang
But yeah for a more complex fold structure, even with various subfolder depth, we will need regex to get what we want
also as an option if you are comfortable you can use custom Python Script TOP for more complex logic in attribute processing
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
5 posts
Joined: 2月 2022
Offline
Thanks for the comments! Learned a lot
  • Quick Links