My naive effort to query the stage inside a Python expression on a parm don't seem to work. Is this even possible?
Specifically, this doesn't seem to work in a python expression:
hou.pwd().editableStage()
But is there some other method I can use? I'd like to drive a parm value inside an HDA based on a specific attribute on a specific prim. For now I'm just using a Python node as a middle-man to retrieve the value from the primitive and push it to the parm, but that seems sloppy.
No it's not possible to get the editableStage() from a parm; you can get a stage though, to get a read-only access to the stage. However I'd recommend reading from the input's stage, to avoid reading from a node's stage when it tries to cook.
Maybe try hou.pwd().inputs()[0].stage()in the parm expression?
You can also try using the Store Global Parms LOP to store properties on the HoudiniLayerInfo prim, to send down the lops node graph (similar to how one might use detail attributes in SOPs)
While there aren't Python docs for USD yet, the C++ class pages aren't too hard to translate to the Python equivalents, and nearly all unit tests on github are in Python, and are an excellent learning resources.
It seems it didn't work because I Used.editableStage() instead of just stage.
Thank you for your quick reply and help !!
Still unable to get it to work inside a loop though.
EDIT:
I could not get it to work I think becouse when used in the same script that generates the stage it hasn`t generated the stage yet so it needs to be split into 2 scripts.