python: Layout functions for nodes

   3377   2   1
User Avatar
Member
34 posts
Joined: 9月 2014
Offline
Hello,

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.

Cheers
Kym
User Avatar
Member
17 posts
Joined: 8月 2012
Offline
Hey Kym,

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 on
subnets = []
# 
subnet = hou.node("/obj").createNode("subnet","subnet1")
subnets.append(subnet)
# layout of subnet nodes with optional spacing
hou.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?

Edit: you find the layout functions here in the “Layout” section: hou.Node docs [www.sidefx.com]

Take care,
Dziga
Edited by dzigakaiser - 2020年2月19日 06:55:05
freelance matte painter & environment concept artist
User Avatar
スタッフ
4454 posts
Joined: 7月 2005
Offline
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.
  • Quick Links