Adding Magnets - more than 5 per side

Hi,

I am creating context diagrams and the style and level of detail means I need to have shapes with evenly spaced magnets, totalling more than just 5, along each edge. It is time consuming to add them manually and even when you do this there is no guarantee that each magnet will snap to the grid, in which case they end up unevenly spaced … which means when using an orthogonal connector the presentation gets screwed up.

Anyway, please there must be a way to do this? I’ve added a simple example of what I’m trying to do, the red arrows are what I’m talking about in terms of alignment issues

I think you should be able to add magnets at specific coordinates of a selected shape using a script.

(Worth choosing View > Magnets from the menu system before you experiment)
Here is a snippet of sample code, showing the -0.0 to +1.0 coordinate system:

-- SIMPLE MAGNET EXAMPLES, North-South, East-West, and four corners 
property plstNSMagnets : {{0.0, -1.0}, {0.0, 1.0}}
property plstEWMagnets : {{1.0, 0.0}, {-1.0, 0.0}}
property plstCornerMagnets : {{1.0, 1.0}, {1.0, -1.0}, {-1.0, -1.0}, {-1.0, 1.0}}
property plstQuarterPoints : {{-0.5, -1}, {0.5, -1}, {1, -0.5}, {1, 0.5}, {-0.5, 1}, {0.5, 1}, {-1, 0.5}, {-1, -0.5}}

tell application id "OGfl"
    tell front window
        repeat with oGraphic in (selection) as list
            if class of oGraphic = shape then
                set magnets of oGraphic to plstNSMagnets & plstEWMagnets & ¬
                    plstCornerMagnets & plstQuarterPoints
            end if
        end repeat
    end tell
end tell

There are a bunch of scripts online for doing this. I have my collection at :

I use OmniGraffle-Add-Magnets.scpt to add N magnets on a side. This script does not clear so you can keep adding different numbers on different edges.

To clear all magnets from selected shape I use OmniGraffle-Clear-Magnets.scpt.

These are derivatives of work by Laurence Scotford .

1 Like

Hello,

Thanks for this Magnet script, it is really helpful. Are their changes that need to be made to the script to work with version 7? I recently upgraded and now the script doesn’t work. I tried deleting it and copying back into the proper folder but still doesn’t work. Thanks.

The selection method seems to be broken in the current build of OG (Test) 7.3

( Worth reporting through OmniGraffle > Help > Contact Omni …, to help it advance in priority )