The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniGraffle General (http://forums.omnigroup.com/forumdisplay.php?f=10)
-   -   Insert 16 magnets (8 couples) centered and evenly distributed (http://forums.omnigroup.com/showthread.php?t=23247)

CPG 2012-01-19 02:51 PM

Insert 16 magnets (8 couples) centered and evenly distributed
 
I know how to add magnets and delete magnets, but it's been impossible to get them to be aligned exactly the same on my rectangle and to be distributed evenly. How can I select multiple magnets and perform these functions?

whpalmer4 2012-01-19 03:41 PM

1 Attachment(s)
Is this an example of what you are trying to achieve? I just used the Properties : Connections editor and selected the choice for 4 magnets on each side.

If this isn't what you are looking for, how about posting a picture?

vidmaven 2012-02-18 04:46 PM

per-side # of magnets + auto-distribute (subgroup divisor)
 
Ideally, specifying a unique number of magnets per side would be possible, with the default behavior being even distribution along each side.
I wouldn't find it inappropriate to limit the polygon [max. # of sides] to 4, but the overall facility would be a huge improvement.
Further, a subgroup feature, allowing groups of magnets to be "clumped" (e.g.: 2 sets of 6 magnets, 2 sets of 2 =16 connections, subgroups, with weighted distribution, maintaining a ratio of >4:1 distance between subgroup separation and group member separation.
[IMG]https://files.me.com/funqsta/wpa9iu[/IMG]

RobTrew 2012-02-18 11:43 PM

Here is an example of how to specify 16 evenly distributed points for the selected shape(s). You can add or reposition custom points by specifying them in virtual coordinates that extend from top left {-1.0, -1.0} down to bottom right {1,1}.

This script gives the cardinal directions, the four corners, and midpoints between corners and edge centres. You can adjust the point lists to whatever you like. There is no need for any kind of symmetry.

[CODE]-- 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[/CODE]

RobTrew 2012-02-19 08:20 AM

And for radially even spacing of the magnets (on a circle shape, for example) you could calculate the coordinates:

[CODE]property plngMagnets : 16
property prStartDegrees : 360 / 32

on run
set lstMagnets to RadialMagnets(plngMagnets, prStartDegrees)
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 lstMagnets
end repeat
end tell
end tell
end run

on RadialMagnets(lngN, rStartDegree)
if lngN < 1 then return {}

set lstMagnets to {}
set rTheta to rStartDegree
set rDelta to 360 / lngN

repeat with i from 1 to lngN
set end of lstMagnets to {sin(rTheta), -(cos(rTheta))}
set rTheta to rTheta + rDelta
end repeat
return lstMagnets
end RadialMagnets


on sin(rDegrees)
(do shell script "echo 's(" & (rDegrees / 180) * pi & ")' | bc -l") as number
end sin

on cos(rDegrees)
(do shell script "echo 'c(" & (rDegrees / 180) * pi & ")' | bc -l") as number
end cos
[/CODE]

vidmaven 2012-02-20 09:04 AM

Great stuff! Thanks, Rob!
In the first example you provide, are the coordinates applied to each of 2 parallel sides(e.g.: NS)? To be honest, I hadn't looked into scripting for 'Graffle - good to know.
I was somewhat surprised to find that magnets don't Snap to Grid. Regarding the scripting example, is consistency of magnet spacing maintained if the rect is resized?

Thanks!
bt

RobTrew 2012-02-20 09:54 AM

3 Attachment(s)
The coordinates are those of a virtual square with top left and bottom right corners at -1,-1 and 1, 1

In the application of the magnets, shapes are treated as transforms of such a square.

North and South have to be applied separately. There is no automatic mirroring.

Probably best to look at the coordinates specified in the script, and get a sense of how they relate to the 3 resultant thumbnails below.

[COLOR="White"]--[/COLOR]


All times are GMT -8. The time now is 05:31 PM.

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