Is there a way to call the nodegraphs layout functions for nodes, given a selection? I can see that there is a
hou.node.layoutChildren
, Is there a way to access the Layout nodes Up / left or right from python?
Also is there a way to know the max outputs for a subnet or create more? i have apile of geo & alembics plugged into a switch node for stamping that id like to clean up, there could be 10, 50 or 100+ depending on the shot. i tried to stick them in a subnet, but the amount of connections from the subnet to the switch seems to get truncated.
to your first question: You can create a list with your created nodes and use the list in the layout function like so (of course you would append all your subnets and not just the one like in the example ):
# node list for positioning later onsubnets=[]# subnet=hou.node("/obj").createNode("subnet","subnet1")subnets.append(subnet)# layout of subnet nodes with optional spacinghou.node("/obj").layoutChildren(items=(subnets),horizontal_spacing=2.0,vertical_spacing=-1.0)
Is there a way to access the Layout nodes Up / left or right from python?
Not sure what you mean. Do you mean you want to control if the layout is horizontal/vertical(see spacing options above)? Or do you want to layout nodes which positions match a certain positional mask (e.g. nodes left of another node)?
Regarding your subnet question: if you look at your other thread I mentioned a different method to instance your assets with which you could just use a merge node in your subnet that merges all assets before passing them to the instancer. If you want to keep your switch setup you could also put the switch into the subnet and use the one output of the subnet, right?
The nework editor “align” and “distribute” functions are implemented entirely in python. You can find the code in the nodegraphalign and nodegraphlayout modules in $HH/python2.7libs.