The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniGraffle > OmniGraffle General
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Script: clearer layout for orthogonal trees Thread Tools Search this Thread Display Modes
[This script has now been replaced by a more general-purpose tool, which does not require Launchbar]

The hierarchical option in Automatic Layout currently bunches parents towards each other, skewing them artificially and asymmetrically away from the centres of their child ranges.

For hierarchies with straight-line connections between nodes, this may give a pleasingly unbuttoned 'botanical' style.

For orthogonal connections, however, it simply damages the signal-to-noise ratio:
  1. Introducing artifacts like jagged three stage connections between a parent and a single child,
  2. imposing asymmetries which are not present in the user's data,
  3. sometimes even making connectors overlap, so that it becomes unclear which parent is attached to which child.
This draft script aims to make orthogonal hierarchies clearer and more legible by properly centring parents over their child ranges, eliminating spurious asymmetries, and ensuring that the link between a parent and a single child is always a simple straight line.

Automatic Layout's standard result the noise, asymmetries and ambiguities are rooted in the fact that this is a non-orthogonal layout merely decorated with orthogonal connectors a diagram in drag:

Converted (by the script) to a true orthogonal layout the structure of the user's data is revealed clearly, without noise, distortion or ambiguity:

The script first runs the built-in Automatic Layout, so that it can discover the order of siblings (the OG Applescript library doesn't offer us this information).
The layout of the tree is then improved by moving shapes to left or right (up and down in the case of a left-to-right tree), to eliminate the unfortunate 'bunching', artifacts, occasional ambiguity, and imposed asymmetry introduced by the Graphviz layout engine.

(Note that OmniGraffle has a bug in which connectors are not always automatically updated after shapes have been moved by applescript - the final flickering is a nudging of each shape to force OG to update all the connectors. This can be switched off by editing:
property pblnUpdateLinks : true
property pblnUpdateLinks : false

To force an update manually - use Cmd A to select the whole diagram, and move it slightly with the mouse. Any misplaced connectors will then jump to their correct position).

Still a draft script, and it has only been tested on the templates and styles which I work with personally, so it's important to back up your diagrams before testing it.


If the script is selected in LaunchBar, you can speed up tree-work by tapping the space bar and entering one or more commands, using the following syntax to:
  1. Adjust the width and/or height of all shapes in visible layers,
  2. switch link updating on or off (i.e. override the default value of pblnUpdateLinks),
  3. adjust the amount of space between rows (rank separation) (in points, not inches),
  4. adjust the object separation (also in points),
  5. change the direction of the layout from top, left, right, or bottom,
  6. change the type of all lines in visible layers, e.g. switch between straight lines and orthogonal links,
  7. change the magnets of all shapes in visible layers (magnets are adjusted automatically by the script when orthogonal trees switch between vertical and horizontal directions).

s={150,100} or size={150,100}
w=150 or width=150
h=100 or height=100

u=f or updatelinks=false
u=t or updatelinks=true

rank separation: r=30 or rank=30 (NB in points, not inches)
object separation: o=15 or object=15 (ditto)

link type: l=[b|c|o|s] or links=[bezier|curved|orthogonal|straight]

direction of layout d=t|l|r|b or direction=(from) top|left|right|bottom

magnets: m={} or just m= will clear all magnets from all shapes in the visible layers.
m=[ns|ew|nsew|corners|c|8] will set magnets of shapes in visible layers to North-South, East-West, NSEW, all four corners, or all corners + all sides.

arrow heads on the lines in the visible layers:
a=[h|t|b|n] or arrows=[head|tail|both|none]

multiple commands should be separated by a single space
d=l l=o r=30 o=0
Relative values:

Values for the w, h, r, and o commands can be prefixed with "+" or "-" to make them relative.
To increase the rank separation by 10 points:
or to shrink the height of all shapes (in visible layers) by 10 points:


Last edited by RobTrew; 2011-11-03 at 06:23 AM.. Reason: Script replaced by a more general tool
A more complex before and after.

For some more complex trees, centring parents over children can even make the diagram marginally more compact, as well as simpler and more legible. (The script preserves automatic layout's object separation settings).

Before (as generated by OG's built-in Automatic Layout):

After (with parents centred over children by the script):

Last edited by RobTrew; 2011-10-29 at 03:46 AM..
Quickly scanning material on the Graphviz engine which OmniGraffle is using, I get the impression that simple trees with parents centred over their children really are beyond the scope of that engine :-)

I hope that this is a misapprehension ...

( but if a clean and compact orthogonal layout can be hacked with a simple applescript by a non-programmer, then I am sure it is not beyond the enormous wisdom of OmniGroup's esteemed collectivity of creative engineers and brilliant wizards :-)

Worth requesting a "Centre parents over children" option for Automatic Layout through OG Help > Send Feedback, I think ...

Added a LaunchBar parameter syntax for making absolute or relative adjustments to the shape sizes and gaps of a tree more rapidly (bypassing the inspector dialogs).

Also allows rapid rotation of the tree around the four possible directions (root at top, left, right or bottom) automating magnet changes when these are required to maintain a well-formed orthogonal tree.

(connector types, arrow directions, and general magnet options can also be rapidly changed through combinations of LaunchBar switches).


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic layout works poorly with orthogonal connectors RobTrew OmniGraffle General 13 2013-05-02 09:53 PM
Better outlines than 003, better trees than OG5 ... RobTrew OmniOutliner 3 for Mac 2 2012-07-07 12:26 AM
Script: Tree Tool - quick formatting and layout of OG hierarchy diagrams RobTrew OmniGraffle General 16 2012-06-07 12:48 AM
Collapsing and expanding simple trees in OmniGraffle RobTrew OmniGraffle General 3 2011-06-11 08:37 PM
Automatic Layout with Orthogonal Lines and Midpoints stonematt OmniGraffle General 0 2008-06-24 12:17 PM

All times are GMT -8. The time now is 12:42 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2023, vBulletin Solutions, Inc.