How to check if node is camera or light with python
3230 6 1-
- Ashen
- Member
- 78 posts
- Joined: May 2018
- Offline
I feel like this is a stupid question, but I just can't seem to figure it out. How would I determine if a node is a special rendering node such as a light or a camera? Is there a property that gets set or something so that mantra picks up on this? How would I quickly access this information for filtering my node searches in Python?
Edited by Ashen - Nov. 20, 2019 14:10:27
-
- goldfarb
- Staff
- 3459 posts
- Joined: July 2005
- Offline
-
- jsmack
- Member
- 7981 posts
- Joined: Sept. 2011
- Offline
-
- goldfarb
- Staff
- 3459 posts
- Joined: July 2005
- Offline
-
- jsmack
- Member
- 7981 posts
- Joined: Sept. 2011
- Offline
That would require hard coding every camera type.
The closest way I can find is using recursive glob and a node filter. It's kind of ugly, but it seems to work.
The closest way I can find is using recursive glob and a node filter. It's kind of ugly, but it seems to work.
obj = hou.node('/obj') stereo_cam = obj.createNode('stereocamrig') cam1 = obj.createNode('cam') cam2 = obj.createNode('vrcam') null1 = obj.createNode('null') light1 = obj.createNode('hlight') cam1 in cam1.parent().recursiveGlob(cam1.path(), hou.nodeTypeFilter.ObjCamera) True cam2 in cam2.parent().recursiveGlob(cam2.path(), hou.nodeTypeFilter.ObjCamera) True stereo_cam in stereo_cam.parent().recursiveGlob(stereo_cam.path(), hou.nodeTypeFilter.ObjCamera) True light1 in light1.parent().recursiveGlob(light1.path(), hou.nodeTypeFilter.ObjLight) True null1 in null1.parent().recursiveGlob(null1.path(), hou.nodeTypeFilter.ObjCamera) False
-
- Ashen
- Member
- 78 posts
- Joined: May 2018
- Offline
You hit the nail on the head jsmack. Somehow mantra knows what nodes are to be used as lights or cameras independent of their node type name. Clever hack with the nodeTypeFilter, though I imagine that it won't scale very nicely. Would be nice to have access to the data it is using to filter them under the hood. It feels like nodeType is missing a method for type class or something.
Edited by Ashen - Nov. 20, 2019 19:06:12
-
- Ashen
- Member
- 78 posts
- Joined: May 2018
- Offline
-
- Quick Links