renochew Posted May 11, 2009 Share Posted May 11, 2009 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. Thanks! Quote Link to comment Share on other sites More sharing options...
graham Posted May 11, 2009 Share Posted May 11, 2009 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 break else: current_box = cwd.createNetworkBox() selected_nodes = hou.selectedNodes() for node in selected_nodes: current_box.addNode(node) current_box.fitAroundContents() Quote Link to comment Share on other sites More sharing options...
renochew Posted May 11, 2009 Author Share Posted May 11, 2009 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.