Search - User list
Full Version: How to split @directory in VEXpressions
Root » PDG/TOPs » How to split @directory in VEXpressions
scareley
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?
tamte
marshall.wang
What did I miss/mistake here?
parameters us Hscript, not VEX and there is no split() function in HScript
scareley
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('/')"`
tamte
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
scareley
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
tamte
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
scareley
Thanks for the comments! Learned a lot
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB