Referencing HDA's location

   1816   2   1
User Avatar
Member
65 posts
Joined: May 2009
Offline
Dear all!

I'm trying to archive an asset for a client which has outside file references (textures mainly). While the asset was living in our project structure it was sufficient to have absolute file names, but now I would like to archive it to a self contained directory structure. The most elegant way would be to reference these files relative to the hda file, which defines the asset. Is it possible?

Thanks in advance,
Mate
User Avatar
Member
191 posts
Joined: Oct. 2018
Offline
It looks like you can use this to get the hda location in python:

yourHDANode.type().definition().libraryFilePath()

It might be easier though to make a parameter for them to point to the base folder, then use that as a reference in your external file paths. They could then change the default for the base folder to wherever they put the files.
User Avatar
Member
65 posts
Joined: May 2009
Offline
Thanks Mkps,

This is exactly what I was looking for. The final content of the top level parameter on the asset that can be referenced from the inside is:

'/'.join(hou.pwd().type().definition().libraryFilePath().split('/')[:-1])

I used the awkward join/split combo, because os.path expects backslashes on windows while Houdini returns slashes.

Cheers,
Mate
  • Quick Links