hopbin9 Posted February 25, 2012 Share Posted February 25, 2012 Hi all, I have SOP geometry that contains about 50 groups, and I need to convert each group into a scene object. I guess each scene object will use a Object Merge SOP for one of the groups. Is there an automated way of doing this? I tried to do this by hand, but after about 20 objects I started forgetting which groups I already used. 1 Quote Link to comment Share on other sites More sharing options...
Macha Posted February 25, 2012 Share Posted February 25, 2012 An easy way would be to name each group with an number at the end. Then, when you object merge name your node in the same manner with an end digit. Use an opdigit('.') expression at the end to get the digit and then just copy paste happily. Another way would be a shelf tool in which you get your selected node and loop through each group and create a few nodes for each of the groups. The trouble with that approach is that you might forget which of your shelf tools it was, or other users can't use it, or it stops working when you update it, etc. Quote Link to comment Share on other sites More sharing options...
edward Posted February 25, 2012 Share Posted February 25, 2012 Just curious, why do you want to break it out into separate objects? Quote Link to comment Share on other sites More sharing options...
ben Posted February 25, 2012 Share Posted February 25, 2012 Not the most elegant solution but this is what I do. Export each group to a bgeo file (see attached file) and then paste the following in a python shell. import os obj = hou.node("/obj") #path to objects directory = "C:\EXPORT" #check if any file in directory if not os.path.isdir(directory): print "No files in directory" # List the files in the specified directory. files = os.listdir(directory) #Create file node and set with obj path for item in files: name = str(item) print name file_path = os.path.join(directory, item) node = obj.createNode("geo", name) geo = hou.node("/obj/"+name) hou.node("/obj/"+name+"/file1").setName(name) fileNode = hou.node("/obj/"+name+"/"+name) fileNode.parm("file").set(file_path) fileNode.setDisplayFlag(True) fileNode.setRenderFlag(True) ExportGroups.hipnc 2 Quote Link to comment Share on other sites More sharing options...
zarti Posted February 25, 2012 Share Posted February 25, 2012 maybe this is not exactly what you want , but this can be turned into a asset and be used totally from OBJ level . you can even combine different Groups from different SOPs also into a single object . .. as you said , this solution is founded on the ObjectMerge SOP sorry , it is not automated , but you can control things better ( i presume ) -- -- groupzCollector_0.hipnc Quote Link to comment Share on other sites More sharing options...
ben Posted February 25, 2012 Share Posted February 25, 2012 I think this is exactly what you're looking for : Extract Groups object tool by Graham http://www.houdinitoolbox.com/houdini.php?asset=25 Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted February 25, 2012 Author Share Posted February 25, 2012 Thanks guys! This python code will do the trick. Just curious, why do you want to break it out into separate objects? I have an .obj file of a spaceship made out of legos. Each brick comes into Houdini as a primitive group, and I want to use each brick in a RDB simulation. I tried making it a fractured object, but then I don't have as much control over each brick. Quote Link to comment Share on other sites More sharing options...
ikoon Posted April 11, 2017 Share Posted April 11, 2017 (edited) Please is there any new automated method for this issue? I had similar problem and solved it temporarily with the Name SOP and then Exploded View SOP (zero scale). Edited April 11, 2017 by ikoon Quote Link to comment Share on other sites More sharing options...
f1480187 Posted April 11, 2017 Share Posted April 11, 2017 @ikoon, did it solve the problem? How? Since it's Python, everything posted so far should still work. If not, I have a similar tool (probably based on Graham's one), which works just fine for me: def extract_groups(selected_nodes): '''Create objects using target object primitive groups.''' if len(selected_nodes) != 1: return with hou.undos.group('Separate Objects'): node = selected_nodes[0] node.setDisplayFlag(False) groups = node.displayNode().geometry().primGroups() for group in groups: obj = node.createOutputNode('geo', group.name(), run_init_scripts=False) merge = obj.createNode('object_merge') merge.parm('objpath1').set(node.path()) merge.parm('group1').set(group.name()) xform = merge.createOutputNode('xform') xform.setDisplayFlag(True) xform.setRenderFlag(True) t = xform.parmTuple('t') t[0].setExpression('-centroid(opinputpath(".", 0), 0)') t[1].setExpression('-centroid(opinputpath(".", 0), 1)') t[2].setExpression('-centroid(opinputpath(".", 0), 2)') obj.parmTuple('t').set([-x for x in t.eval()]) extract_groups(hou.selectedNodes()) 1 Quote Link to comment Share on other sites More sharing options...
ikoon Posted April 12, 2017 Share Posted April 12, 2017 Thank you F1. I have attached the files. I am still newbie and I am maybe confused by this: we cannot simply set or detect the "3D Connected" geometry connectivity by intrinsic or other attribute. This is "blackboxed" am I right? For example these two scenarios: - artificially connect separate disconnected geometries into one "baked" geometry (for the bullet collision, I faked this by packing those separate geometries) - set "artificial" disconnectivity to single island of connected geometry ... or in other words ... set connectivity of primitives by an attribute (or group) disregarding the 3D positions (which was also discussed here and I solved partially with Exploded View) collision connected convex.hiplc Quote Link to comment Share on other sites More sharing options...
f1480187 Posted April 12, 2017 Share Posted April 12, 2017 (edited) We can't set custom connectivity, so, yes, name attribute is used to perform such things. You can create name for the pig's groups in a similar way you did with spheres, then also pack into fragments. This will split geometry in a same way Exploded view did. The thread is from 2012, where packed workflow wasn't implemented in Houdini, probably. Therefore using OBJ level was involved. What kind of automation do you need? Edited April 12, 2017 by f1480187 Quote Link to comment Share on other sites More sharing options...
ikoon Posted April 12, 2017 Share Posted April 12, 2017 F1 thank you very much for explanations. As "automated method" I have ment any new SOP since the 2012 ... something as the Convertline SOP is new, and useful. So the packing is new since then, great 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.