cloudfx Posted September 15, 2008 Share Posted September 15, 2008 Hi all, I got a lot of sop networks (about 300) in my obj network because I imported fragment geometry from 3dsmax. I am trying to create a script that could open into each sop network and copy everything, and paste it into one single sop network(Master Sop Merge). Can anybody show a good example of this kind of work around?? Thanks a lot! -j Quote Link to comment Share on other sites More sharing options...
rdg Posted September 15, 2008 Share Posted September 15, 2008 You could create a smart bundle like /obj/Sphere*_geo/what_ever_the_last_sop_is_called and object merge it in to your master object Maybe the /obj/Sphere*/what_ever_the_last_sop_is_called works directly in the object merge, too. Quote Link to comment Share on other sites More sharing options...
graham Posted September 15, 2008 Share Posted September 15, 2008 (edited) You will basically want to use hou.copyNodesTo for this. This function takes a list of node objects and moves them to a new location. You could do something like this: I can't guarantee it works because I don't have Houdini open but it should obj = hou.node('/obj') # Get all the geo nodes that have the correct name. objchildren = [child for child in obj.children() if child.childTypeCategory() == hou.sopNodeTypeCategory() and child.name().find('Sphere') is not -1] # Create a new container. container = obj.createNode('geo', 'container') # Destroy any children. for child in container.children(): child.destroy() # Create the merge sop. merge = container.createNode('merge') for object in objchildren(): # Get all the sop nodes in the geo object. sops = object.children() # Find the display node and set a comment to keep track of it. displaynode = object.displayNode() displaynode.setComment('DISPLAY') # Copy all the sops to the new container. newnodes = hou.copyNodesTo(sops, container) # Find the node that was the display sop in the copied nodes, connect it to the merge and clear the comment. for node in newnodes: if node.comment() == 'DISPLAY'): merge.setNextInput(node) node.setComment('') # Destroy the object. object.destroy() # Layout all the children in the container. container.layoutChildren() Edited September 15, 2008 by graham Quote Link to comment Share on other sites More sharing options...
cloudfx Posted September 15, 2008 Author Share Posted September 15, 2008 You could create a smart bundle like /obj/Sphere*_geo/what_ever_the_last_sop_is_called and object merge it in to your master object Maybe the /obj/Sphere*/what_ever_the_last_sop_is_called works directly in the object merge, too. What do you mean by a smart bundle? I never used it. Can you tell me how do I use it?? Thanks!! Quote Link to comment Share on other sites More sharing options...
cloudfx Posted September 15, 2008 Author Share Posted September 15, 2008 (edited) You will basically want to use hou.copyNodesTo for this. This function takes a list of node objects and moves them to a new location.You could do something like this: I can't guarantee it works because I don't have Houdini open but it should Thanks for writing a code! Should I just open a python shell and type the line one by one? I never used python shell in houdini. Only experience that I have with script is Max Script in 3dsMax.. Thanks a lot! Edited September 15, 2008 by Jae Yoo Quote Link to comment Share on other sites More sharing options...
rdg Posted September 15, 2008 Share Posted September 15, 2008 http://www.sidefx.com/docs/houdini9.5/ref/panes/bundles Smart bundlesNormally you define the contents of bundles by dragging nodes onto the bundle in the bundle list pane. However, you can also define smart bundles. These are like smart playlists in iTunes: they automatically include all nodes that match a pattern you define. But it seems smart bundles are still auto convert to bundles upon close of Houdini Quote Link to comment Share on other sites More sharing options...
anim Posted September 15, 2008 Share Posted September 15, 2008 do you really need to script it? or you just want to merge all fragments to one node there is a combine button in the modify shelf but if this is a scripting exercise, please ignore my post 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.