Jump to content
eldrich

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

Recommended Posts

Posted (edited)

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

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
Share on other sites

Thanks David, 

I'd rather learn the Houdini way than transpose a load of destructive Maya habits.
I'll give this a go today, thank you for helping. 

Share this post


Link to post
Share on other sites
Posted (edited)


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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×