How to check if node is camera or light with python
3465 7 1- Ashen
- Member
- 78 posts
- Joined: 5月 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 - 2019年11月20日 14:10:27
- goldfarb
- スタッフ
- 3463 posts
- Joined: 7月 2005
- Offline
- jsmack
- Member
- 8041 posts
- Joined: 9月 2011
- Offline
- goldfarb
- スタッフ
- 3463 posts
- Joined: 7月 2005
- Offline
- jsmack
- Member
- 8041 posts
- Joined: 9月 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: 5月 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 - 2019年11月20日 19:06:12
- Ashen
- Member
- 78 posts
- Joined: 5月 2018
- Offline
- colorbleed
- Member
- 19 posts
- Joined: 1月 2024
- Offline
> Would be nice to have access to the data it is using to filter them under the hood.
Agreed - interested to hear how Houdini itself filters these. E.g. it can also detect LOP Import Camera in `/obj` is 'a camera' but there doesn't seem to be a `hou.ObjNode` way of querying whether it's a camera in that sense.
Agreed - interested to hear how Houdini itself filters these. E.g. it can also detect LOP Import Camera in `/obj` is 'a camera' but there doesn't seem to be a `hou.ObjNode` way of querying whether it's a camera in that sense.
-
- Quick Links