Search - User list
Full Version: PDG filerename problem
Root » PDG/TOPs » PDG filerename problem
scottp
I'm having trouble using the filerename node. The rename field seems to be limited to a string expression, and I found it surprisingly difficult to find a way to express the rename that I want.

I have a terrain file called terrain_x0_y0.png, and I want to rename it to terrain_x0_y0_uint16.png.

How can I express this? Ideally, I'd like to use the string functions in python, because it's easy to do a string replace, or splitting, etc. I tried setting the node language to python and set a keyframe to force evaluating the string in python.

I couldn't even get the filename pdg attribute into the newpath parameter after trying all of these variations:
kwargs('filename')
workItem().environment
workItem().stringAttribute('filename')
workItem().envLookup('filename')

Finally, I tried this expression that seemed to do the trick, but it seemed especially awkward. Is this the best expected solution?
`@directory`/`substr(@filename, 0, strlen(@filename) - 4)`_uint16.png
BrookeA
Hi there, I've attached a .hip file that demonstrates Hscript (left branch) and Python (right branch) based approaches.

Hopefully this helps! Let me know if you have any questions.
scottp
Thank you for the nice example. My issue was that I didn't know how to evaluate a Python expression in a filename. I am inferring that you set a keyframe on the filename with Python as the expression language. Let me know if I'm wrong about that.
BrookeA
Yes, that is correct!
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