perxt

perxt

About Me

Connect

LOCATION
Not Specified
WEBSITE

Houdini Skills

Availability

Not Specified

Recent Forum Posts

Importing geometry (obj) so it recognizes separate objects? Sept. 22, 2009, 4:01 p.m.

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