Jump to content

Is there a way to query the current context in Python?


magneto

Recommended Posts

Hi,

I want to know if the current context in the network editor is SOP, or VEX, or DOPs, etc. I could get the type from hou.selectedNodes, but a selection has to exist and this seems a little indirect.

Is this the only way, or is there some other way to get the current context in Houdini?

Thanks :)

Link to comment
Share on other sites

You can get it by asking the pane tab for it's current location, then getting the child type category for that.

For example, panetab15 is a network editor tab at /obj.

>>> hou.ui.findPaneTab('panetab15')
<hou.NetworkEditor panetab15>
>>>hou.ui.findPaneTab('panetab15').pwd()
<hou.Node at /obj>
>>> hou.ui.findPaneTab('panetab15').pwd().childTypeCategory()
<hou.NodeTypeCategory for Object>
# Now inside a geo object (/obj/geo1)
>>> hou.ui.findPaneTab('panetab15').pwd()
<hou.ObjNode of type geo at /obj/geo1>
>>> hou.ui.findPaneTab('panetab15').pwd().childTypeCategory()
<hou.NodeTypeCategory for Sop>

  • Like 2
Link to comment
Share on other sites

Hi Graham, I looked at the pane.selectPosition and it returns a position like you said, after you click somewhere in the network editor. Would there be a way to force or cancel this mode so I don't have to click? Because otherwise it attaches the node to my pointer, but I just want to passively query the position. That's why I thought maybe there is a way to force dropping the node to get the current position.

I will keep digging. Thanks again :)

I found out that it's possible by using ctypes which is what I ended up doing for people who want to know :)

Edited by magneto
Link to comment
Share on other sites

  • 2 years later...

Hey Ryan, are you able to share an example of how you did this? Thanks!

 

Hey man, I stopped using ctypes long ago and now do it this way:

 

pane = kwargs['pane']
contextname = pane.pwd().childTypeCategory().name()
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...