Number selected shapes script for OmniGraffle

Example numbered shapesAutomatically sequentially numbers selected shapes in OmniGraffle. It's rather complicated to figure out what order it should do them in!

Using

  1. Download Applescript icon number_shapes.zip (12 KB).
  2. Install the script.
  3. In OmniGraffle select some shapes, then choose Script > Number selection.

Tips and other uses

After making the numbers the script selects them all, which is the ideal time to apply any style changes to them all at once. Alternatively, you can select them later, either using the selection palette, or by hitting the Select all in layer button when the appropriate layer is active.

About to zap a layerFor some reason there's a difference between a layer being selected and active in terms of selecting and adding things. The selected one is the one that looks selected. The active one is the one with the tiny pen next to it, which is also shown in the little layer menu, in the status bar, on the left of the image below.

If you want to delete all the numbers, because you've made some more shapes and all your numbers are out of sync, it's easiest to delete the entire "Automatically generated numbers" layer they've been made on.

If you try to run the script with a layer named "Automatically generated numbers" it'll complain at you. Two options: Re-name the layer to something else, or delete it.

By default the script considers shapes to be in the same row if they're offset vertically no more than half the average height of all the shapes you're numbering. (See offset_tolerance below.)

alignment of shapesIn the example shown here shape 2 is 2, rather than being 1. Even though it's higher up than the other everything else, it's not high enough to not be associated with the other blue ones.

The little black-sheep-type-thing, number 9, is number 9 rather than 8 as it's more than 50% of the average height of all the shapes lower down than the green ones.

This all works quite nicely in a lot of cases, but may produce unexpected, confusing, or just plain wrong results if you have lots of shapes with very different sizes.

The script's been made (for a change) to be quite easily changeable by people who really don't understand what's going on, like me when I look it about a week from now. Double-click on the script file, and it should open in Script Editor. The following are right at the top of the script:

label_offset
Default: 5. Diagonal down/left offset from bottom-left corner of shape.
layer_name
Default: "Automatically generated numbers".
label_font
Default: "Optima-Bold".
label_font_size
Default: 12.
label_rounding
Default: 10.
label_prefix/suffix
Default: Empty string.
label_width/height
Default: 14. These aren't really used, as the label auto-sizes to accommodate the text.
offset_tolerance
Default: 0.5. What proportion of the average shape height a shape's allowed to drop before it's considered to be on the next row, as discussed above. Should probably be ≤ 1.

Known 'features'

Things to maybe get around to some nice day

Acknowledgements

Version history

1.0 (2005-10-20)
Initial release. Apparently works with OmniGraffle version 4.0. Should also work fine with corresponding Pro versions of OmniGraffle.