Houdini Python help

   3445   4   2
User Avatar
Member
51 posts
Joined: Feb. 2016
Offline
Hello, I'm pretty new to scripting with Python in Houdini and I'm trying to learn it a bit in my free time.
I decided to start with a alembic expand shelf tool, since is one of the thing that I have do the most in Houdini. This is what I got until now

#Alembic name
#Create null
abc=hou.node(“/obj/env”)
resize = hou.node(“obj”).createNode(“null”, node_name=“RESIZE”)
abc.setInput (0,resize)
hou.node(“obj”).layoutChildren()
abc.setDisplayFlag(False)

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

#Create merge node and null
merge = hou.node(“obj/destination/”).createNode(“merge”)
null = hou.node(“obj/destination/”).createNode(“null”, “OUT”)
merge.outputConnectors()
null.setInput (0,merge)
null.setDisplayFlag(True)
null.setRenderFlag(True)

#Get all alembic archive nodes at object level and put them in to a list (in case there is more than one alembic imported)(i=/obj/alembicname):
alembic_archives =
for i in hou.node(“obj”).children():
if i.type().name()==“alembicarchive”:
alembic_archives.append(i)

#Create object merge node
alembic_nodes=
count=0
for n in alembic_archives:
for x in n.allSubChildren():
if x.type().name()==“geo”:
obj_merge = hou.node(“obj/destination/”).createNode(“object_merge”)
obj_merge.parm(“xformtype”).set(“local”)
unpck = hou.node(“obj/destination/”).createNode(“unpack”)
unpck.setInput (0,obj_merge)
alembic_nodes.append(x)

#Move the display flag and move into a good position
for i in hou.node(“obj/destination/”).children():
if i.type().name()==“unpack”:
merge.setNextInput(i)

#Layout node
hou.node(“obj/destination/”).layoutChildren()

My main problem is that I would like to use the information coming from the list “ alembic_node ” as a path to the object path 1 parameter inside the object merge. I notice that the set expression doesn't allow me to use list or I'm just using this wrong and trying to do something in the worst possible idea.

obj_merge.parm(“objpath1”).set(alembic_nodes)


I hit a brick wall and have no idea how to solve this. If anyone could help me would be amazing
Thank you so much!

Alice
User Avatar
Member
806 posts
Joined: Oct. 2016
Offline
Moin,

I am off the office and cannot try scripts in Houdini right now, but from the looks of it, you are trying to poke a Python construct into a string value on a Houdini node. That won't work. The “objpath1” where you are trying to “set(” a Python list looks like it expects a path to a Houdini object/node somewhere in the scene, so it's a simple string pointing to a single node (something like “/obj/my_geo/somewhat_out_null”).
If you want to combine several elements (that you can access through Houdini paths), you either have to create several object-merge-nodes and merge their outputs together using a … wait for it … MERGE node (couldn't resist, sorry) OR you have a look at your source geometry to check whether you can merge all output there into a single “transfer object” and obj-merge that in your final step.

I hope this helps, apologies for not being able to post a script right away.


Marc
---
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
User Avatar
Member
51 posts
Joined: Feb. 2016
Offline
Hello Malbrecht,
thank you so much for your prompt reply. The idea behind the script is that I would like not to connect manually one by one all the path from the generated object merge to the respective geometry object inside the alembic archive. At the moment the path of each geometry is getting store in a list called “alembic_nodes”, but as you said the “objpath1” input want a path and doesn't accept a list. Is at the moment creating an object merge for each geometry inside the alembic archive and merge them together into a merge.
I'm not sure I understand how would you tackle this problem. Maybe what I would need is access to each element of my list and put it in the object merge.

Don't know if I make sense.Thank you again so much for the reply I put also two screenshot of how the scene look like after I used my shelf tool.
Alice

Attachments:
Capture_01.PNG (10.9 KB)
Capture.PNG (41.2 KB)

User Avatar
Staff
3455 posts
Joined: July 2005
Offline
this is an old script that may not work
but it might give you some pointers

add this to your shelf
select an Alembic Archive Object
then hit the shelf button

what this should do is:
make a new Object
create an object merge that grabs ALL the alembic SOPs
and then in each of the Geometry Objects in the Archive:
makes a network that returns that geometry from the new object.

if it works you'll see what is going on

Attachments:
abcprocess.shelf (3.4 KB)

Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
51 posts
Joined: Feb. 2016
Offline
Hello goldfarb,
thank you so much for your script. I can confirm that work like a charm! I will have a deeper look into it and learn as much as I can from it.
Thank you so much
Alice
  • Quick Links