Jump to content
Sign in to follow this  

Add selected node to a networkbox

Recommended Posts

Hi all, I am new to python scripting in Houdini, just wondering how can I add a bunch of nodes to a networkbox, the only function I found relative to add node to networkbox is the addNode function, which seems to only add single node to a networkbox.

Any advance would be much appreciated.


Share this post

Link to post
Share on other sites

Looking at the docs for hou.NetworkBox looks like all the planned methods for the class have been implemented so it would seem addNode is the best that we will be getting for now. However this is really more than enough since we can just loop to add our nodes. Doing something like the following code should work, assuming you create a tool that you can access in the tab menu. It gets the selected nodes, looks for a selected network box to use and if not it creates a new one. Can't guarantee this code actually works since I haven't tried it but it should provide the general idea if not.

activepane = kwargs["pane"]

if not isinstance(activepane, hou.NetworkEditor):
	raise hou.Error("No Network Editor found.")

cwd = activepane.pwd()

netboxes = cwd.networkBoxes()

current_box = None
for box in netboxes:
	if box.isPicked():
		current_box = box
	current_box = cwd.createNetworkBox()

selected_nodes = hou.selectedNodes()

for node in selected_nodes:


Share this post

Link to post
Share on other sites

Thanks Graham, your suggestion is more than enough to get me started, I will test your script right away.

I will post my final script if it really need some tweaking in order to get it to work.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this