Jump to content

copy/paste Looping through sop to sop


cloudfx

Recommended Posts

Hi all,

I got a lot of sop networks (about 300) in my obj network because I imported fragment geometry from 3dsmax.

I am trying to create a script that could open into each sop network and copy everything,

and paste it into one single sop network(Master Sop Merge).

post-3325-1221497556_thumb.jpg

Can anybody show a good example of this kind of work around??

Thanks a lot!

-j

Link to comment
Share on other sites

You could create a smart bundle like

/obj/Sphere*_geo/what_ever_the_last_sop_is_called

and object merge it in to your master object

Maybe the /obj/Sphere*/what_ever_the_last_sop_is_called works directly in the object merge, too.

Link to comment
Share on other sites

You will basically want to use hou.copyNodesTo for this. This function takes a list of node objects and moves them to a new location.

You could do something like this:

I can't guarantee it works because I don't have Houdini open but it should :)

obj = hou.node('/obj')
# Get all the geo nodes that have the correct name.
objchildren = [child for child in obj.children()
				 if child.childTypeCategory() == hou.sopNodeTypeCategory()
					 and child.name().find('Sphere') is not -1]
# Create a new container.
container = obj.createNode('geo', 'container')
# Destroy any children.
for child in container.children():
	child.destroy()
# Create the merge sop.
merge = container.createNode('merge')


for object in objchildren():
	# Get all the sop nodes in the geo object.
	sops = object.children()
	# Find the display node and set a comment to keep track of it.
	displaynode = object.displayNode()
	displaynode.setComment('DISPLAY')
	# Copy all the sops to the new container.
	newnodes = hou.copyNodesTo(sops, container)
	# Find the node that was the display sop in the copied nodes, connect it to the merge and clear the comment.
	for node in newnodes:
		if node.comment() == 'DISPLAY'):
			merge.setNextInput(node)
			node.setComment('')
	# Destroy the object.
	object.destroy()
# Layout all the children in the container.
container.layoutChildren()

Edited by graham
Link to comment
Share on other sites

You could create a smart bundle like

/obj/Sphere*_geo/what_ever_the_last_sop_is_called

and object merge it in to your master object

Maybe the /obj/Sphere*/what_ever_the_last_sop_is_called works directly in the object merge, too.

What do you mean by a smart bundle?

I never used it. Can you tell me how do I use it??

Thanks!!

Link to comment
Share on other sites

You will basically want to use hou.copyNodesTo for this. This function takes a list of node objects and moves them to a new location.

You could do something like this:

I can't guarantee it works because I don't have Houdini open but it should

Thanks for writing a code!

Should I just open a python shell and type the line one by one?

I never used python shell in houdini.

Only experience that I have with script is Max Script in 3dsMax..

Thanks a lot!

Edited by Jae Yoo
Link to comment
Share on other sites

http://www.sidefx.com/docs/houdini9.5/ref/panes/bundles

Smart bundles

Normally you define the contents of bundles by dragging nodes onto the bundle in the bundle list pane. However, you can also define smart bundles. These are like smart playlists in iTunes: they automatically include all nodes that match a pattern you define.

But it seems smart bundles are still auto convert to bundles upon close of Houdini :(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...