In the schematic view all nodes can be spread all over the place, in fact so far or near to each other that you are getting display errors and the graph will start flickering.
Thankfully you can script the position of these node positions. The solution was to write a quick script to reorder them based on the hierarchy. I hope this will help others struggling with this problem as well.
Here is the script to do this.
import pyfbsdk as fb
evilnodes = []
for each in fb.FBSystem().Scene.Components:
if getattr(each, 'SetSchematicPosition', None):
evilnodes.append(each)
def sort_by_hierarchy(nodes):
tree = {}
sort_by_hierarchy_recursive(tree, None, nodes)
return tree
def sort_by_hierarchy_recursive(tree, parent, nodes):
# find children
children = [n for n in nodes if n.Parent == parent]
# build a subtree for each child
for child in children:
# start new subtree
tree[child.Name] = {}
# call recursively to build a subtree for current node
sort_by_hierarchy_recursive(tree[child.Name], child, nodes)
sortedEvilNodes = sort_by_hierarchy(evilnodes)
iteratorX = 0
iteratorY = 0
for each in xrange(0,len(evilnodes)):
if evilnodes[each].Name in sortedEvilNodes:
iteratorX += 100
iteratorY = 0
else:
iteratorY += 20
evilnodes[each].SetSchematicPosition(iteratorX, iteratorY)
And yes in case you are bored out of your mind you can also arrange them in a circle. Just change line 30-39 to this.x = 0
y = 0
radius = 300
substeps = 64
for each in xrange(0,len(evilnodes)):
x = int((radius * math.cos((math.pi/substeps)*each)))
y = int((radius * math.sin((math.pi/substeps)*each)))
evilnodes[each].SetSchematicPosition(x, y)

COMMENTS
LEAVE A COMMENT