Sum numbers script for OmniGraffle
A simple script which adds up the numbers in objects and makes a new object with the total, for the OmniGraffle drawing package.
Latest version: More sensible about finding numbers in a shape's text. (2006-02-27)
- Download sum_numbers.zip (8 KB).
- Install the script.
- In OmniGraffle open a new document and make a few shapes with some numbers in them.
- Select > Sum Numbers.
- (Optional: Note any large error messages that appear, then e-mail me to get it fixed. Skip the last step.)
Tips and other uses
If you run the script once, then change some numbers, and you've not deleted the shape that the first run created, then the total in the shape is simply updated. (I'm frightfully proud of this.)
If some shapes are selected then only those shapes are considered in the total.
Only the last number found in a shape will be used for the addition. All of the following texts would be considered to have the value of 25:
Item 3: 25
...that's about all there is. This script doesn't really lend itself to exciting pictures.
- There is very little error checking. While this is a big improvement over the normal situation with my scripts of "No error checking at all", it's still far from ideal. As such, if you do anything out of the ordinary the script will almost certainly give strange—or no—results. If you do do something funny, OmniGraffle will give you the option to edit the script. Feel free! Let me know if you come up with anything great.
- For some reason the text alignment and some formatting (bold etc.) of the text in the 'total' shape doesn't seem to get preserved if you run the script multiple times with the same total object.
- Multiple total objects are always drawn in the same place. This shouldn't really be a problem, as it should be using the same object anyway, but if you delete the small script snippet that is in the shape's Action property you'll end up with lots of them.
- Which leads us nicely to: The total shape must have a special value at the start for it to be recognised. Shouldn't be a huge problem I would think, but just so you know.
Things to maybe get around to some nice day
- Parse unusually formatted numbers like "100,000.5".
- Make the script run when you click with the Action tool on the total shape.
- Maybe some more error checking here and there might be a good idea.
- When adding things like 1.5 and 1.5, make the result display as 3, rather than 3.5.
- A similar script for averages would probably be handy sometimes. Not sure it deserves its own page though.
- Other suggestions and comments are more than welcome.
- Suggested by Jim Anders of Kaidan, via the OmniGraffle mailing list.
- 1.1 (2006-02-27)
- Improved parsing of text. A shape with the text "24, some number: 25", would be counted as 25.
- 1.0 (2006-02-23)
- Initial release. Apparently works with OmniGraffle version 4.1.1. Should also work fine with corresponding Pro version of OmniGraffle.