Jump to content

Python: how to determine if a node is a ROP node


jonp

Recommended Posts

Maybe I'm missing it, as I only searched for about 10 minutes, but how does one determine if a node is of type hou.RopNode?

For example, the rop_alembic SOP node is of type "rop_alembic", but its category is "Sop".  How do I determine that it's actually a render node?

One possible answer is to do this:

is_rop = hasattr(node, 'render')

...but that can give false positives.

 

-Jon

Link to comment
Share on other sites

That is true, but when I try to access 'geometry()' on that node, it will raise an error that mentions it being a 'hou.RopNode' class!  How do I get to that type definition myself?  That seems like the magic bullet.

Link to comment
Share on other sites

There is misleading collision between Python types and Houdini operator types. In Houdini terms (by calling hou.Node.type() method), rop_geometry is a Sop node, also true inside Operator Type Manager window:

rop_sop_rop_sop.png

In Python terms, this node will be an instance of hou.RopNode, no matter where it is:

isinstance(node, hou.RopNode)
type(node) == hou.RopNode

Before now, I was sure that every node within one network will be same type for both Houdini and Python.

Edited by f1480187
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...