Jump to content

Convert SOP groups into scene Objects


Recommended Posts

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.

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)
	fileNode = hou.node("/obj/"+name+"/"+name)


  • Like 2
Link to comment
Share on other sites

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 )





Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 5 years later...

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 by ikoon
Link to comment
Share on other sites

@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:

    with hou.undos.group('Separate Objects'):
        node = selected_nodes[0]

        groups = node.displayNode().geometry().primGroups()

        for group in groups:
            obj = node.createOutputNode('geo', group.name(), run_init_scripts=False)

            merge = obj.createNode('object_merge')

            xform = merge.createOutputNode('xform')

            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()])



  • Thanks 1
Link to comment
Share on other sites

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)

set of connected primitives - bullet packed.PNG

set of connected primitives - groups.PNG

collision connected convex.hiplc

Link to comment
Share on other sites

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 by f1480187
Link to comment
Share on other sites

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 :)

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.

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...