salik Posted November 24, 2016 Share Posted November 24, 2016 I have just started out learning Houdini APIs and am trying to use it to do some scripting.. In the following code, I am trying to remove the file node whenever a geo node gets created. # Create a new geo node geo_node = hou.node('/obj').createNode('geo') new_geo_node = geo_node.path() # Get the children within the new geo node check_for_children = hou.node(new_geo_node).children() # Gets the file sop file_node_type = hou.nodeType(hou.sopNodeTypeCategory(), "file") # Deletes the file sop within the new geo node for child in check_for_children: if child.type() == file_node_type: child.destroy() I am not very sure if this logic of mine is in the correct path in terms of Houdini, because when I script it, it is pretty much python-orientated.. Is this the best approach to check and remove nodes within, from another node? Quote Link to comment Share on other sites More sharing options...
bunker Posted November 24, 2016 Share Posted November 24, 2016 "createNode" returns a node object so you don't need to use node.path() and then hou.node()geo_node = hou.node('/obj').createNode('geo') for i in geo_node.children(): i.destroy() only one file SOP is created by default inside geo nodes so you can simplify furthergeo_node = hou.node('/obj').createNode('geo') geo_node.children()[0].destroy() weirdly enough, this works toogeo_node=hou.node('/obj').createNode('geo').children()[0].destroy() 2 Quote Link to comment Share on other sites More sharing options...
salik Posted November 24, 2016 Author Share Posted November 24, 2016 Thanks bunker! It works like a charm! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.