[SOLVED]DAE Batch Import?

   2935   2   1
User Avatar
Member
2529 posts
Joined: June 2008
Offline
Hi All,

I have 100 .DAE files I want to import.

Does Houdini offer any batch import features?
Edited by - Dec. 12, 2014 12:24:03
Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
443 posts
Joined: Sept. 2012
Offline
If you have sequence then file sop can be used. Otherwise File>Import and ctrl click to select files.

You can import .dae by clicking on File>Import>Geometry or File>Import>Collada
User Avatar
Member
2529 posts
Joined: June 2008
Offline
While you can CTRL-Click on the file names in the dialog box, that produces an invalid string of files for the import tool and it fails to import anything.

I did manage to modify a Python based import routine for my needs. Thanks to Petr for helping out with this.


# import bunch of dae files from specified directory.
# Petr Zloty

# Modified by Enivob.
# The goal is to remove the redundant subnetwork levels generated by the default DAE import
# and just present a single GEO node with file import nodes followed by transforms all merged together.

import hou, os

# directory path for *.dae files (back slashes for windows path)
dir = “d:\\_Sort\\DAE\\”

dae_files =[name for name in os.listdir(dir) if os.path.isfile(dir+name) and (os.path.splitext(name).lower()==“.dae”)]

# check for collada_scene object
new_node = hou.node(“/obj/collada_scene”)
temp_renamed = None
if new_node != None:
new_node.setName(“_new_temp_name_”)
temp_renamed = new_node

# custom prefix for new name
prefix =“collada_”

# import files from directory
for i,file in enumerate(dae_files):
dae_file_path_elements = # Blank out the file list for every import.
new_name = prefix+os.path.splitext(file).replace(“ ”,“_”)
hou.ui.setStatusMessage(“importing: {0}”.format(file), hou.severityType.Message)
command = “colladaimport ‘”+dir+file+“’”
command = command.replace(“\\”, “/”)
hou.hscript(command)
import_node = hou.node(“/obj/collada_scene”) # Find default name that hscript import command creates.
# Look two levels deep first.
subnet_node = hou.node(“/obj/collada_scene/nifid_0_node/nifid_2_node”) # Navigate the specialized node structure from Nifskope export.
if subnet_node == None:
# Try looking one level up.
subnet_node = hou.node(“/obj/collada_scene/nifid_0_node”)
if subnet_node != None:
for child in subnet_node.children():
if child.type().name() == ‘geo’:
# Fetch the transform from the GEO node, we will append this as an actual TRANSFORM node following a FILE node in our GEO.
tx = child.parm('tx').eval()
ty = child.parm('ty').eval()
tz = child.parm('tz').eval()
rx = child.parm('rx').eval()
ry = child.parm('ry').eval()
rz = child.parm('rz').eval()
loc = (tx,ty,tz)
rot = (rx,ry,rx)
# We need to fetch the file path from the grandchild file node in this GEO node which currently resides in the subnetwork.
for grandchild in child.children():
if grandchild.type().name() == ‘file’:
s = grandchild.parm('file').eval()
dae_file_path_elements.append((s,loc,rot)) # Save data needed to reconstruct this file refernce with a transform.

import_node.destroy() # We no longer need this node created by the DAE import routine.

# Use the file list to create and merge all these file references under a single GEO node, NOT subnetwork.
ob = hou.node(“/obj”).createNode('geo',new_name, run_init_scripts=False)
merge = ob.createNode('merge')
for j,(file_path,loc,rot) in enumerate(dae_file_path_elements):
node_name = “dae_element_%i” % j
temp_file = ob.createNode('file',node_name, run_init_scripts=False)
temp_file.parm('file').set(file_path)
node_name = “dae_xform_%i” % j
xform = ob.createNode('xform',node_name, run_init_scripts=False)
xform.parm('tx').set(loc) # Set position.
xform.parm('ty').set(loc) # Set position.
xform.parm('tz').set(loc) # Set position.
xform.parm('rx').set(rot) # Set rotation.
xform.parm('ry').set(rot) # Set rotation.
xform.parm('rz').set(rot) # Set rotation.
xform.setFirstInput(temp_file)
if j == 0:
merge.setFirstInput(xform)
else:
merge.setNextInput(xform)

merge.setDisplayFlag(1)
# Specialized follow up transform for my needs, you may not need to do this for your entries.
ob.parm('rx').set(-90)
ob.parm('ry').set(180)
ob.layoutChildren()
else:
print("Subnet or sub-subnet not found in “ % new_name)


# rename original collada_scene back
if temp_renamed != None:
temp_renamed.setName(”collada_scene“)

hou.node(”/obj/").setCurrent(True, True)
Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
  • Quick Links