Importing geometry (obj) so it recognizes separate objects?

   36053   11   3
User Avatar
Member
120 posts
Joined: July 2009
Offline
Whenever I import an .obj file that has more than one object in it houdini doesn't seem to recognize this and just lumps it into one object which is very probelmatic when the objects are touching each other so that I can't easily select the polygons from just that object to uv map it.

In any other 3d program I am able to open the file and it shows as separate objects.. is there a way to do this in houdini?
User Avatar
Member
349 posts
Joined: Aug. 2006
Offline
Add a connectivitySOP, this will create an attribute called $CLASS. So you want to name it so its called object_$CLASS or what ever suits you fine.
Next add a partitionSOP, and in the rule area type: object_$CLASS.

If you middle click the node you should have a list of primative groups. These groups are created by Houdini finidng primatives that are adjacent to each other, hence all primatives in a single mesh.
Now add a deleteSOP and set it to “delete non-selected” and choose your first: “object_” and you shall be left with just that single object. Copy and paste the delete node and shift the object number up by one, rinse and repeat then merge all seperate branches back together after you have done all your mapping ect, etc.

I would imagine a foreachSOP would be good for doing this automagically, using stamping to cycle through the primgrouplist making sure not to merge the results. However foreach isnt a sop ive used that much.
User Avatar
Member
120 posts
Joined: July 2009
Offline
Thanks for the detailed response.. will try that tomorrow.. I had been importing to 3ds max and then exporting as an .fbx which also takes care of the issue but wanted to figure a way to do it just in houdini.
User Avatar
Member
665 posts
Joined: July 2005
Offline
How is the OBJ created?

In Maya there should be an option to export Group names that does this seperation…


cheers,
-j
User Avatar
Member
120 posts
Joined: July 2009
Offline
I use a few different programs for creating objects.. I don't use maya at all, usually I start in a nurbs program and then it goes to silo and then out to houdini
User Avatar
Member
120 posts
Joined: July 2009
Offline
Ragupasta, I tried what you said but I can't seem to figure out how to select the individual “objects” once I have done the first two steps as I wasn't able to select anything when I followed the way you said… when I select from the menu that lists the different objects it doesn't seem to select anything and then with the delete sop it just deletes the entire object..

The method I had used with 3ds max to .fbx isn't working well for me now since 3ds max is, well, not exactly a first rate progam when it comes to highly subdivided objects so if I put it there first it basically turns my nicely sub'd objects from silo into garbage.. for now I am just saving each part I need separate as a separate object and piecing it together in houdini.


I think this is something sidefx should really consider improving for future versions as even basic programs like silo are able to recognize the .obj files as consisting of mutliple objects.. thanks for the help on this though as I greatly appreciate it
User Avatar
Member
7717 posts
Joined: July 2005
Online
Note that if you want to maintain transform hierarchy information, then there's no way to do it via the .obj format. This is why you need a higher-level format like collada or fbx.
User Avatar
Member
120 posts
Joined: July 2009
Offline
I forgot about collada maybe I can figure a way to get the files into that format
User Avatar
Staff
3455 posts
Joined: July 2005
Offline
whenever I use obj I tend to follow these steps:

file SOP > mesh.obj
group SOP > delete all groups
attribute SOP > delete all attributes
either
connectivity SOP > object_$CLASS + partition SOP
or
use a series of delete nodes to separate the different parts, I select them by entering the delete tool and using “0” to “Select Connected Geometry”

then later I can use a groupCop or an attributTransfer to bring back the groups/attributes I need, if any.
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
1 posts
Joined: Sept. 2009
Offline
Hi, I needed this too so I wrote a script to do it. It creates a different SOP network (to keep it clean) and uses object_merge nodes for each group of your objs.


# Creates object_merge nodes from primitive groups
# of a file node.
#
# Usage: change the FILE variable to the full path of your
# *.obj (or *.bgeo). Then, copy-paste this into
# your Python Source Editor (“window” dropdown)
# and click apply.

FILE = ‘$HIP/geo/groups.obj’
# change the above line to point to your *.obj i.e.
# /home/user/file.obj or CsomeFolder/file.obj

# initialize shortcuts
import hou as h
n=h.node

# build geo nodes
INGEO = n('/obj').createNode('geo', ‘INGEO’, run_init_scripts=False)
OUTGEO = n('/obj').createNode('geo', ‘OUTGEO’, run_init_scripts=False)

# create a file SOP and set its disk path
fileNode=INGEO.createNode('file', ‘fileNode’)
fileNode.parm('file').set(FILE)

# create as many object_merge SOPs as there are groups and connect
for child in INGEO.children():
groups = h.hscriptExpression('primgrouplist(“%s”)' % fileNode.path()).split()
for i in groups:
r=OUTGEO.createNode('object_merge')
r.setName(“mrg_”+i)
r.parm('objpath1').set(fileNode.path())
r.parm('group1').set(i)
w=OUTGEO.createNode('file')
w.parm(“filemode”).set(“write”)
w.setName(“rw_”+i)
w.setInput(0, r, 0)
w.parm(“file”).set(“$HIP/geo/$HIPNAME/”+i+“.bgeo”)
User Avatar
Member
617 posts
Joined: Aug. 2008
Offline
i would recommend try FBX, and work very well for me, well some time doesn't carry the materials with it but they say that will be fix in the next build and you don't need to worry to create groups or delete since all of them transfer in separate object just like you see in Maya or xsi.

is not you can delete each part that you don't want, go back to the main OBJ and select another part and delete the rest. as people commented above .
User Avatar
Member
648 posts
Joined: July 2005
Offline
what perxt said.
name your objects in the soruce app in a logical manner,
then separate using group names in houdini, EG:
'hero_pants'
can be extracted from ‘hero’ by deleting unselected groups: *pants*
you can also use *ants* if capitalization is in doubt
This way you can separate everything of relevance, EG:
hero_pants, hero_pants_buttons, hero_pants_belt, hero_pants_emitter, etc..
  • Quick Links