Search - User list
Full Version: How to know if a node is camera (include cam HDA) ?
Root » Houdini Lounge » How to know if a node is camera (include cam HDA) ?
jerry7
Hi,

I created an HDA myCam. And need to do something in python for Object/cam and myCam.
Though I can test if the type.name() is “myCam”. I want a more general method to know if the node belongs to camera.
Are there any way to know if a node is a camera (include cam HDA)?

Thanks!
malbrecht
Hi,

have you tried reading the documentation? Node type for “cam” is … wait for it … “cam” :-)

Documentation says “node.type()” gives you the node type, so in Python you would do something like
hou.node("/obj/myCam").type()
, which would return “cam”. You could traverse all your “/obj” nodes and check for each node's type whether it is “cam”.


Marc
Jonathan de Blok
malbrecht
Hi,

have you tried reading the documentation? Node type for “cam” is … wait for it … “cam” :-)

Documentation says “node.type()” gives you the node type, so in Python you would do something like
hou.node("/obj/myCam").type()
, which would return “cam”. You could traverse all your “/obj” nodes and check for each node's type whether it is “cam”.


Marc

…type().name() would be the thing that returns the actual name string, important since you want to be able to compare it to the string “cam”
jsmack
Jonathan de Blok
malbrecht
Hi,

have you tried reading the documentation? Node type for “cam” is … wait for it … “cam” :-)

Documentation says “node.type()” gives you the node type, so in Python you would do something like
hou.node("/obj/myCam").type()
, which would return “cam”. You could traverse all your “/obj” nodes and check for each node's type whether it is “cam”.


Marc

…type().name() would be the thing that returns the actual name string, important since you want to be able to compare it to the string “cam”

That only works for the houdini cam. The OP is asking how to tell if any node is a camera class, not type. I'm not sure if there is a way other than recursive glob, which isn't very friendly for simple masking. I've resorted to hard coded lists of type names for this purpose.
doctorbob
hey all,

as a followup to this, i trawled through the HTOA properties source and discovered they were using the node.type().definition().extraInfo() thingo - it has a “subtype=cam” entry for camera derived types.

It certainly works for my own custom camera OTLs.

i have no idea whether this is a formal houdini thing that you can 100% rely upon, but as hou has no concept of type def subclasses, it's the closest that i've ever seen (short of globbing parms and saying “yep, this looks like a camera… ish”)

hope this helps.

cheers,
chrisg
jsmack
doctorbob
It certainly works for my own custom camera OTLs.

It doesn't work on non-otl cameras though, since their types don't have a ‘definition’, such as the built in ‘cam’ type and lopimportcamera type.

Using
mycam in mycam.parent().recursiveGlob(mycam.name(), filter=hou.nodeTypeFilter.ObjCamera)
has been the only sure fire way I've found. There's got to be something simpler.
doctorbob
well, that's a super useful snippet. thanks!

cheers,
chrisg
elovikov
Hi all!

Looks like these classes are not exposed to HOM. As a workaround you can use inlinecpp to check if OBJ node is a camera. Though you need Visual Studio installed (or Xcode on OSX) to use it. So no simple way afaik

Try to put this in session module:
import inlinecpp

utils = inlinecpp.createLibrary("utils", 
    includes="#include <OBJ/OBJ_Node.h>",
    function_sources=["""
bool isCamera(OBJ_Node* node)
{
     return node->castToOBJCamera() != NULL;
}
"""])

Then you can check OBJ nodes like this
node = hou.node("obj/cam1/")
geo_node = hou.node("obj/geo1/")
print hou.session.utils.isCamera(node) # True
print hou.session.utils.isCamera(geo_node) # False

That would work with builtin and hda cameras
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB