add all otls in file to a scene

   2187   0   1
User Avatar
Member
300 posts
Joined: March 2011
Offline
made a little snipped that can help you add all digital assets in an otl to a scene, so things can be sorted out easily. can be used as a shelf button although I'd add some code to change the otl in question,

one could also oviously loop over say all otl's in a folder.
NOTE IT CLEARS THE SCENE AND SWITCHES TO MANUAL
(to prevent any weird stuff going on and all the otls cooking.

anyways the code hope it's useful to someone:



import os

#otl file to extract
my_otl_file = “%s/otls/OPcustom.otl” % hou.homeHoudiniDirectory()

#clear scene: and set update to manual to prevent extranious cooking
hou.hipFile.clear()
hou.setUpdateMode(hou.updateMode.Manual)

#create containers:
obj = hou.node(“/obj”)
sop = obj.createNode(“geo”, “sopnet”, run_init_scripts=False) rop = obj.createNode(“ropnet”, “ropnet”, run_init_scripts=False) cop = obj.createNode(“cop2net”, “cop2net”, run_init_scripts=False) chop =obj.createNode(“chopnet”, “chopnet”, run_init_scripts=False)

#place otls
for definition in hou.hda.definitionsInFile(my_otl_file):
print definition.nodeTypeCategory().name() + “/” + definition.nodeTypeName()

if “Sop” in definition.nodeTypeCategory().name():
print “sop”
sop.createNode(definition.nodeTypeName())
if “Object” in definition.nodeTypeCategory().name():
print “object”
obj.createNode(definition.nodeTypeName())
if “Chop” in definition.nodeTypeCategory().name():
print “Chop”
chop.createNode(definition.nodeTypeName())
if “Rop” in definition.nodeTypeCategory().name():
print “Rop”
rop.createNode(definition.nodeTypeName())
if “Cop” in definition.nodeTypeCategory().name():
print “Cop”
cop.createNode(definition.nodeTypeName())

print “———”

print “:COMPLETED”
  • Quick Links