Get LopNode.stage() with specific context options

   365   2   1
User Avatar
Member
19 posts
Joined: 1月 2024
Offline
I'm looking to get the LopNode.stage() with specific context options, but I can't find a LopNode.stage(context_options=my_options) argument or LopNode.cook(context_options) and then LopNode.stage().

I have a bunch of USD Render ROP nodes in /out where each ROP specifies its own context options overrides. Now, I want to validate some things in the USD stage at the LOP path the USD Render ROP would be evaluating. Preferably I'd be able to do something along the lines of:

context_options = get_context_options(rop)
lop_path = rop.parm("loppath").evalAsNode()
with hou.contextOptions(context_options):
    stage = lop_path.stage()


But this is just pseudocode of course.

So,

1. If there's function somewhere that could act as the get_context_options from the ROP node that'd be nice. I checked some loputils and loptoolutils but couldn't find any.
2. And of course some good way to get the stage of the LopNode with those context options from the ROP node.
Edited by colorbleed - 2024年10月25日 05:31:01
User Avatar
Member
19 posts
Joined: 1月 2024
Offline
For now I ended up computing the context options from the ROP myself and and writing a context options context manager to apply them temporarily. The code is here [github.com].
User Avatar
スタッフ
4523 posts
Joined: 7月 2005
Offline
No, there is no way to do this in python right now. I think the right solution would be to add an optional "context_options_override" parameter to the hou.LopNode.stage() method (which is the function that you would generally use to cook a LOP node and access the resulting stage). Feel free to RFE this.
  • Quick Links