Stage query inside a Python Expression?

   3373   8   2
User Avatar
Member
235 posts
Joined: Oct. 2014
Offline
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.
Edited by Tim Crowson - Jan. 6, 2021 12:07:20
- Tim Crowson
Technical/CG Supervisor
User Avatar
Staff
4159 posts
Joined: Sept. 2007
Offline
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)
I'm o.d.d.
User Avatar
Member
235 posts
Joined: Oct. 2014
Offline
Ah that works perfectly! Thanks for this tip!
- Tim Crowson
Technical/CG Supervisor
User Avatar
Member
88 posts
Joined: Feb. 2021
Offline
Anny idea if GetChildPrimPaths() is implemented in some way ?
User Avatar
Staff
4159 posts
Joined: Sept. 2007
Offline
Try GetChildren(), or GetAllChildren() if you have inactive/unloaded/abstract child prims.

https://graphics.pixar.com/usd/release/api/class_usd_prim.html#a2619563fc9180d8ead597944fd7f6ec7 [graphics.pixar.com]

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.

HTH!
I'm o.d.d.
User Avatar
Member
88 posts
Joined: Feb. 2021
Offline
What are you using as search terms ?
I can`t really find anything.

Only unrelated projects called pxr.

Also could u b so kind to have a look at this thread ->

https://www.sidefx.com/forum/topic/82025/?page=1#post-352968 [www.sidefx.com]
User Avatar
Member
190 posts
Joined: Dec. 2016
Offline
Hello I`m trying to make a script to convert assets to lops.

Im currently stuck trying to get all the geometry subnets to be assigned the correct material in a component Material.

I am however, unable to get the traverse command to work.
node = hou.node('/stage/MTM_PropCargo_component/comp_mat_1')
stage = node.editableStage()

for prim in stage.Traverse():
    # Access or edit the prim
    print(prim)
    pass


trows me an error because


stage = node.editableStage() = null


Using

stage = node.inputs()[0].editableStage()

did not fix
so I`m a bit confused how to actually get my stage
Edited by NicTanghe - Jan. 4, 2023 18:29:41

Attachments:
MTM_topsimport_H_v1.hiplc (5.2 MB)

User Avatar
Member
235 posts
Joined: Oct. 2014
Offline
You have to specify which input you want to query from (even if a node only has one input, you still need to specify it). Try this?

stage = node.inputs()[0].stage()
- Tim Crowson
Technical/CG Supervisor
User Avatar
Member
190 posts
Joined: Dec. 2016
Offline
The
 [0]
did not appear because of the formatter.

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.
Edited by NicTanghe - Jan. 5, 2023 13:20:19
  • Quick Links