Python Tool for import alembic

   3352   3   1
User Avatar
Member
51 posts
Joined: Feb. 2016
Offline
Hello everyone,
I'm a Houdini Junior and I'm building a small tool in Python to help me out with repetitive tasks. In my pipeline, I need to import really often alembic from Maya, that I will then use for examples as collider for my simulations. I usually have to manually select all the geometry from the alembic and create a new geo node with an object merge inside for each part of the alembic that I need. I'm trying to build a shelf tool that will manually do this for me. Searching online, I found a tool that I'm changing to achieve my personal tool. I'm a noob at Python and I'm doing my best to learn it.

After getting part of the code right I got stack at this point. I need to connect all the children inside an object to a merge node. This is what I've got:

for i in hou.node(“obj/destination/”).children():
hou.node(“obj/destination/merge”).setNextInput(hou.node(“alembic”), merge_index=0, unordered_only=False)

I'm pretty sure is completely wrong. There's anyone with good Python knowledge that can help me out?
It would be amazing

Thank you
Alice
User Avatar
Staff
3455 posts
Joined: July 2005
Offline
might be helpful to see the whole script you using…

you can use:
for i in hou.node(obj/destination/).children():
    merge.setNextInput(i)

hope that helps
Edited by goldfarb - Nov. 27, 2018 17:18:12
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
51 posts
Joined: Feb. 2016
Offline
goldfarb
might be helpful to see the whole script you using…

you can use:
for i in hou.node(obj/destination/).children():
    merge.setNextInput(i)

hope that helps


This is all the script but I still did not modify it. I've modified a script of another Houdini user and I'm trying to change it

#Create empty geo node:
destination = hou.node(“obj”).createNode(“geo”, node_name=“destination”)

#get all alembic archive nodes and put them in to a list:
alembic_archives =
for i in hou.node(“obj”).children():
if i.type().name()==“alembicarchive”:
alembic_archives.append(i)

#get alembic geo nodes inside alembic archives
alembic_nodes=
for i in alembic_archives:
for x in i.allSubChildren():
if x.type().name()==“alembic”:
alembic_nodes.append(x)

#copy alembic nodes to destination geo node
hou.copyNodesTo(alembic_nodes,destination)

#remove leftover alembic archive nodes
for i in alembic_archives:
i.destroy()

#create a merge node, move the display flag and move into a good position
merge = hou.node(“obj/destination/”).createNode(“merge”)
merge.setDisplayFlag(True)
merge.moveToGoodPosition()

alembic_children=
for i in hou.node(“obj/destination/”).children():
hou.node(“obj/destination/merge”).setNextInput(hou.node(“alembic”), merge_index=0, unordered_only=False)

# Get sopNodeType for the file SOP
file_nodes = hou.nodeType(hou.sopNodeTypeCategory(), “file”)
User Avatar
Member
51 posts
Joined: Feb. 2016
Offline
goldfarb
might be helpful to see the whole script you using…

you can use:
for i in hou.node(obj/destination/).children():
    merge.setNextInput(i)

hope that helps

Thank you so much for your reply! It's really helpful

  • Quick Links