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: Tree Tool - quick formatting and layout of OG hierarchy diagrams Thread Tools Search this Thread Display Modes
A generalised tool which gives:
  1. Clearer orthogonal layouts for OmniGraffle hierarchical diagrams,
  2. correction of automatic layout's row separation bug,
  3. very quick formatting of OG trees (tree directions, shapes, fills, strokes, shadows, sizes etc) using simple typed commands (see below).
For use with or without LaunchBar. (With LaunchBar, passing '?' as a parameter will display a simple help file).

Offers orthogonal trees (parents centered over children), as an alternative to the non-orthogonal tree layouts which are generated by OG's Graphviz-based Automatic Layout. Also corrects rank separation errors created by a known bug in the code of Automatic Layout (uneven gaps between rows).
With the c=false switch, it can be used for quick formatting, and row gap error correction, with Automatic Layout's own non-orthogonal layouts.

(A spin-off from an earlier script, which it replaces).



(The Graphviz engine supports orthogonally-styled links, but not, as yet, orthogonal trees, in which the line descending from parent to the centre of the children-line hits that line at 90 degrees – this happens to be the kind of tree that my own work frequently requires. Hitherto I have been resorting to www.inspiration.com, which is decoratively less sophisticated, but has translated text outlines into true orthogonal trees since the early 90s, and also offers graphic tree-folding, hoisting etc.).

(NB It is important to back up your diagrams before experimenting with this draft script).

The current option switches (used in the dialog, or from LaunchBar) are:

Direction of tree layout:
d=[t|l|r|b] ( top-down, left-right, right-left, bottom-top )
Size of shapes:
w=150
w=+10 ( increase )
h=100
h=-10 ( decrease )
(wh|hw sets both)
Gaps between Rows and Objects (in points, not inches):
r=30
r=+5
o=15
o=-5
Type of shapes:
s= (no shapes - plain text rectangle - no border, no filll, no shadow)
s=somestring etc
( example: s=cir for circles )
s=? (choose from list)
Type of links:
l=[b|c|o|s] ( bezier, curved, orthogonal, straight )
Arrows:
a= (none)
a=[h|t|b|n] ( at head, tail, both, or neither )
Magnets:
m= (none)
m=[nsew|ns|ew|corners|c|8] ( North-South East-West etc)
[note that the script automatically adjusts magnets when it changes the layout direction of an orthogonal tree]
Stroke of shapes:
ks= (no stroke)
ks=3
ks=+1
ks=? (pick color)
Stroke of lines:
kl= (no stroke)
kl=3 (3pt)
kl=+1 (increment)
kl=? (pick color)
Fill of shapes:
f= (no fill)
f=[n|s|l|r] (none, solid, linear, radial)
f=? (pick color)
Shadow of shapes:
shs= (no shadow)
shs=- (no shadow)
shs=+
shs=? (pick color)
Shadow of lines:
shl= (off)
shl=-
shl=+
shl=? (pick color)
Corner radius:
[crs | scr] (corner radius of shapes)
[crl | lcr] (corner radius of lines)
cr (corner radius of both shapes & lines)
Script behavior:
u=t ( force link updating=true )
c=f ( center parents over children=false )
c= (ditto)
c=true (center parents over children)
c=t (ditto)
Multiple options:
Separate with a single space
l=o r=30 d=l o=5
(=links:orthogonal, row gap 30pt,
Left-Right tree, 5pt gap between objects
)
Attached Files
File Type: applescript TreeTool-148.applescript (59.8 KB, 1024 views)

Last edited by RobTrew; 2012-01-07 at 03:24 PM..
 
Updated to accept cm and inch measurements in the formatting and separation commands, as well as in the default points.

(In addition to warning if a diagram is not a tree, it now also draws attention to any closed loops (cycles) and switches off orthogonal layout accordingly).
 
Ver 1.0 fixes some layout issues with particular tree geometries.
 
Ver 1.08
  • Adds text-size adjustments,
  • generalizes some fixes for particular layout issues,
  • allows for further abbreviation of commands (r+10 ts-1) etc,
  • and only re-runs automatic layout after commands which require it [c- d=l r+5 o-2 u+ etc], allowing for quicker adjustments to formatting issues which don't affect layout.

Note that the simple command c- is like running OG's built-in Automatic Layout but correcting errors introduced by its known row separation and object separation bugs (ie ensuring that row gaps and node gaps are consistent, and are as specified in the Automatic Layout inspector).

(c+ does the same, but also changes the layout to ensure that there are no dog's leg connectors to single children, and that all parents are symmetrically centered over their child ranges)

--

Last edited by RobTrew; 2011-11-23 at 12:42 PM..
 
Ver 1.30
  • Adds sub-tree operations to the target command. You can limit the scope of all formatting operations either to the sub-tree(s) of any selected shapes or lines, or to all shapes outside those sub-trees.
    t=t (formatting target is sub-tree)
    t=x (formatting target is all except sub-tree)
  • Adds text color operations - you can use a color picker tc=?, specify a grey scale numerically tc=.6, tc=60%, or tc=32767, clear colors to black tc=, or just specify red tc=r :-)
  • Fixes a few tree layout issues for special cases.

--

Last edited by RobTrew; 2012-01-02 at 02:37 AM.. Reason: ver 1.35 further added row/level operations
 
Ver 1.36
  • Adds row/level operations. t=r specifies the formatting target(s) as all shapes/lines on the same level as the selected shapes/lines.
  • Fixes abbreviated commands (ts+ lk- etc) for sub-tree and level targets.
 
Rob,

Thanks for this script, you have obviously spent a great deal of time working on it.

best wishes

Simon
 
Thanks, Simon. I hope you find it useful.

The layout algorithm is still a first order hack, and I've discovered at least one tree geometry for which it still needs more work.

I may need to stand back and think more deeply - lots of commercial software provides good and reliable packing of orthogonal trees (with parents centered over child ranges), and I'm sure that there are better algorithms out there if one looked a little harder, or thought a little more carefully.

Who knows - in the fullness of time Omnigroup might even implement one – no word on that yet :-)

(In the meanwhile, my current project involves producing a lot of these trees quite quickly, so I wasn't inclined to wait ...)
 
PS one irritating OG bug (known and documented) is that connectors moved by script are not always properly refreshed in the GUI.

Sometimes re-running the script will fix them. Otherwise the solution is to force a repaint by selecting the whole diagram and nudging it slightly.
 
Quote:
Originally Posted by RobTrew View Post
Otherwise the solution is to force a repaint by selecting the whole diagram and nudging it slightly.
Wouldn't it be easier to write a script to do that last step? ;-)
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script: Generate radial diagrams from outlines RobTrew OmniGraffle General 3 2012-09-03 12:26 PM
Odd behavior - line tool rearrances shapes? [A: template with auto-layout enabled was chosen] erickhill OmniPlan General 2 2012-06-27 03:02 PM
Script: clearer layout for orthogonal trees RobTrew OmniGraffle General 3 2011-10-31 02:10 PM
Script for formatting size based on incoming lines muntzing OmniGraffle General 7 2010-10-14 07:28 AM


All times are GMT -8. The time now is 09:48 PM.


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