Python in Houdini

   3539   4   1
User Avatar
Member
6 posts
Joined: 3月 2014
Offline
Hi everyone I'm getting ready to setup some destruction in Houdini for one of my finals and I need to write a script that will go into each geometry node from my alembics and cut / paste them all into one single geometry node. I'm new to python in Houdini and I'm just getting overwhelmed by creating simple lines of code like creating a single geometry node. I've written scripts in Python for Maya but Houdini it seems like I'm not understanding things or just trying to over complicate things but basically this is what I'm trying to do.

create empty geo node

select all alembic geometry nodes

store them into an array

then for the file inside the alembic

cut the file, paste into the empty geo node

and delete all the empty alembic geometry nodes.

Any tips or advice would be really appreciated. I know scripts are suppose to make life easier and right now my mind just gets overwhelmed from every error I'm getting. Hopefully what I'm trying to do makes sense if not I'll post an example file.

Christian Olan-Geddes
User Avatar
Member
86 posts
Joined: 1月 2009
Offline
This should do the trick I think:

#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()
User Avatar
スタッフ
3463 posts
Joined: 7月 2005
Online
instead of the copy method I'd use an object _merge node
I have a few scripts that do all this…I'll try to find them
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
6 posts
Joined: 3月 2014
Offline
badhairday
This should do the trick I think:

Wow thank you! It seems like it's doing the trick. I also just learned that you could import Alembics all in one hierarchy. Guess the trick is to see which method would be faster to organize.

Christian Olan-Geddes
User Avatar
Member
6 posts
Joined: 3月 2014
Offline
arctor
instead of the copy method I'd use an object _merge node
I have a few scripts that do all this…I'll try to find them

Sweet thanks, I just learned you can import the alembic all as one hierarchy. I'll look into some blast expressions for reorganizing the different pieces for the different names.

Christian Olan-Geddes
  • Quick Links