python - filter nodes by type

   13135   6   1
User Avatar
Member
23 posts
Joined: 11月 2011
Offline
I feel kind of stupid for asking this because I expected it to be really easy, but how would I get lets say all “Texture” VEX nodes in the whole script via python?

Cheers

Sebastian
User Avatar
Member
299 posts
Joined: 1月 2010
Offline
Might be a better way but you could do it with hou.node(“/”).allSubChildren() to get all nodes in the hip file and then loop through and check what nodeType they have.

EDIT: And ofc replace “/” with the path to your Network that contains the Texture nodes.
Drive, monkey, drive!
User Avatar
Member
1908 posts
Joined: 11月 2006
Online
You could do something like this to get the hou.NodeType for the operator, than ask for its instances.
node_type = hou.nodeType(hou.vopNodeTypeCategory(), “texture”)
node_type.instances()
(<hou.VopNode of type texture at /obj/geo1/vopsop1/texture1>,)
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
23 posts
Joined: 11月 2011
Offline
Thanks graham, works beautifully.

Investigating further this is not what I wanted. Actually I am trying to get a list of all images used in the current houdini file. The approach with just getting the texture nodes does not work because the map parm might be connected to a parameter node (promoted) so the map parm does not update. I have been looking into this but could not find out how. How do I find all images in a session in a general way (not just for mantrasurfaces, but for all textures used)?
obviously what I have been doing for maya and nuke a thousand times works in a completely different way in houdini….
User Avatar
Member
1908 posts
Joined: 11月 2006
Online
Take a look at the hscript ‘opextern’ command.

You could also use the getExternalReferences() function in this module, as it is just a wrapper around opextern.

http://houdinitoolbox.com/houdini.php?asset=38 [houdinitoolbox.com]
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
23 posts
Joined: 11月 2011
Offline
thanks, this will do the trick!
User Avatar
Member
304 posts
Joined: 5月 2006
Offline
whoa, I didn´t know about the “instances” method! What a great timesaver! I was looping through all nodes and comparing to get nodes of the same type.
Javier Meroño
FX TD.
  • Quick Links