node type

   6584   2   0
User Avatar
Member
224 posts
Joined: June 2009
Offline
I have a question about the distinction between Node and NodeType in the Python hou module.

In the docs for hou.Node class http://www.sidefx.com/docs/houdini10.0/hom/hou/Node [sidefx.com], its says:

“The base class for all nodes in Houdini (objects, SOPs, COPs, etc.) An instance of this class corresponds to exactly one instance of a node in Houdini…”

Then, in the same docs, it says:

"Be careful not to confuse nodes with node types. A node is an instance of a node type. For example suppose /obj/geo1/box1 is a box SOP. It has its own unique name (box1) and its own copies of parameter values. It is an instance of the box SOP node type…"

But I am still confused.. :?

So, lets consider this box node.
>>> b = hou.node('/obj/box_object1/box1')
>>> print type(b)
<class ‘hou.SopNode’>
>>> print b.name()
box1
>>> bt = b.type()
>>> print type(bt)
<class ‘hou.SopNodeType’>
>>> print bt.name()
box
>>> print bt.nameWithCategory()
Sop/box

So for our box, we can get both an instance of SopNode and of SopNodeType. I guess that SopNodeType is more general than SopNode - is that right.

And why the extra class? Since a class is already a type, you could have all the methods of SopNodeType inside the SopNode class, which would seem more straightforward.
Patrick
User Avatar
Member
7714 posts
Joined: July 2005
Offline
All nodes of the same type share the same underlying node type class. A node type will exist regardless of whether any nodes of it exists.

>>> box1 = hou.node('/obj/geo1/box1')
>>> box2 = hou.node('/obj/geo1/box2')
>>> box1 == box2
False
>>> box1.type() == box2.type()
True
>>> box_type == box1.type()
>>> box1.destroy()
>>> box2.destroy()
>>> box1

ObjectWasDeleted: Attempt to access an object that no longer exists in Houdini.
>>> box2

ObjectWasDeleted: Attempt to access an object that no longer exists in Houdini.
>>> box_type
<hou.SopNodeType for Sop box>
User Avatar
Member
224 posts
Joined: June 2009
Offline
Thanks for the reply. I was thinking something like that. I did actually check to see if two boxes would share the same type object, like this:
>>> b1 = hou.node('/obj/geo1/box1')
>>> b2 = hou.node('/obj/geo1/box2')
>>> id(b1.type())
439870608
>>> id(b2.type())
439871088

The id's are not the same, so they must be different objects. But I did not do the equality test.
Patrick
  • Quick Links