Add node via script

   2582   4   2
User Avatar
Member
218 posts
Joined: March 2006
Offline
Hi all,
I'm new with scripting in Houdini. I have tons of objects imported via FBX out of a CAD-software and I need to append UV-coordinates to a over 100 of them. It's easy to select them, but isn't it possible to insert a UV-unwrap sop automatically with a script?

Thanks for help
Detlef
User Avatar
Member
106 posts
Joined: June 2011
Offline
You can do something like this.



myNodes = hou.node(“/obj”).children()

for node in myNodes:
if node.type().name() == “geo”:
node.createNode('uvunwrap')

User Avatar
Member
218 posts
Joined: March 2006
Offline
thanks for the fast reply.
That is what I need but how can I connect the last node with my new node?
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
for geo_node in geo_nodes:
# Find the geometry object's display node.
displayNode = geo_node.displayNode()

# Create an output node from it.
uv = displayNode.createOutputNode(“uvunwrap”)

# Set the display flag on the new node to be true.
uv.setDisplayFlag(True)

# Set the render flag to the new node if it was set on the old display
# node (which it probably was, so you could probably hard code True instead)
uv.setRenderFlag(displayNode.isRenderFlagSet())
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
218 posts
Joined: March 2006
Offline
Wow… this works for me, thanks a lot!

import hou

selected_nodes = hou.selectedNodes()

for selected_nodes in selected_nodes:

displayNode = selected_nodes.displayNode()
uv = displayNode.createOutputNode(“uvunwrap”)
uv.setDisplayFlag(True)
uv.setRenderFlag(displayNode.isRenderFlagSet())
  • Quick Links