Jump to content

Coming from Maya: How do I separate an obj file SOP into multiple objects, at origin with centred pivots, many times?


eldrich

Recommended Posts

Apologise for noob questions, I've only about 100hrs of Houdini so far, after over a decade of Maya use as a lighting TD. 
I have a file SOP of kitbash models from the link below. The come in as one mesh, obviously

I'd like them as individual objects at the origin with centered pivots.

There's no polySeparate, of course - but I can select points and modify-tab > extract and then in the object_merge node select transform: into Specified Object

But this kitBash SOP has a hundred things in it. So:

How would I go through all the separated hulls and create new objects from each? 
Sounds like a job for a Python, which is probably how I'd approach this in Maya. 

"for each hull in fileSop:" kind of thing. 

I realise there's the 'Maya' way of thinking I need to kinda drop, but at the moment it's the only way I know. 
Thanks in advance!

Obj from here : https://gumroad.com/olegushenok



 

Edited by eldrich
Link to comment
Share on other sites

i guess the geometry can be separated by group names or by some attribute. if you want a separate objects, like /geo/obj1 .. /geo/obj1000 - which I wouldn't recommend as it will be a nightmare to work with (i understand thou for Maya person this kind of idea makes complete sense) - anyways, if you want to do that, i recommend using a Python script that will extract pieces for you into and individual containers, or you could try TOP network i presume, and batch process that stuff. Or you can use a loop to export each attribute value as a separate file on disk. And there are probably more options how to approach it. What I would do is also a Python script, but I would split the geometry into multiple streams inside of the original object, each containing one poly group. I do that often with poly groups. The script is as follows and you can save it easily as a shelf tool. You select the node inside of your geo container and run the script, which should populate your network with number of outputs, one for each group:

selNode = hou.selectedNodes()[0]
selNode.setPosition([0,0])
if len(hou.selectedNodes()) == 0:
    hou.ui.displayMessage("Make your selection first", title = "Error")
else:
    listGroups = selNode.geometry().primGroups()
    groupsNum = len(listGroups)
    hou.clearAllSelected()
 
    for prim in listGroups:
        createDel = selNode.createOutputNode("blast", "OBJ_"+prim.name())
        createDel.parm("group").set(prim.name())
        createDel.parm("negate").set(1)
        createDel.parm("removegrp").set(1)
        createDel.setSelected(True, clear_all_selected = False)
    
selNode.setPosition([(groupsNum),0])
hou.ui.displayMessage("Created " + str(groupsNum) +" objects")

 

cheers. D.

 

edit: to put the individual pieces into origin with centered pivot use for loop per group (per attribute value) with transform SOP in there (before you run the script). pivot can be easily centered by hscript expression "center('../'+opinput('.',0), D_X)" - without quotes and you'd have to do it for each axis (this one obviously works for world X axis, written like this it centers to the geometry of connecting node). Centering the object itself is then done by putting the negated valued into the transform XYZ parameters.

Edited by davpe
  • Like 2
Link to comment
Share on other sites


Another easier way to get separated object is simply from Maya to convert your file to FBX, which allows you to recover all the objects separately.
I know this is not the best way to learn Houdini.
But really the question is what do you want to do with these objects. Having the objects separated is really Maya's (or other DCCs) plilosophy.
Coming from Maya & C4D, I fully understand how you feel.
However, kitbashes is often complete collections of objects grouped together in a single file. And wanting to separate them is legitimate.
But, depending on how the obj file was saved, it may not contain material groups, in which case the script provided by davpe will not work (thanks to him anyway as I also get it :) ).
In this case try the FBX method.

Edited by flcc
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...