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

 
Insert 16 magnets (8 couples) centered and evenly distributed Thread Tools Search this Thread Display Modes
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?
 
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?
Attached Thumbnails
Click image for larger version

Name:	Screen shot 2012-01-19 at 4.37.54 PM.png
Views:	727
Size:	77.9 KB
ID:	2224  
 
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.

Last edited by vidmaven; 2012-02-18 at 06:26 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

Last edited by RobTrew; 2012-02-19 at 01:36 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

Last edited by RobTrew; 2012-02-19 at 01:21 PM.. Reason: Made the code slower but more legible ... :-)
 
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
 
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.

--
Attached Thumbnails
Click image for larger version

Name:	Screen shot 2012-02-20 at 18.47.08.png
Views:	454
Size:	7.4 KB
ID:	2280   Click image for larger version

Name:	Screen shot 2012-02-20 at 18.48.05.png
Views:	427
Size:	7.2 KB
ID:	2281   Click image for larger version

Name:	Screen shot 2012-02-20 at 18.48.40.png
Views:	427
Size:	7.1 KB
ID:	2282  

Last edited by RobTrew; 2012-02-20 at 11:02 AM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to distribute objects evenly vertically/horizontally? [A: Alignment Inspector] johnlawrence OmniGraffle General 6 2012-06-04 06:03 AM
Evenly distributing magnets Kaz219 OmniGraffle General 0 2009-02-26 04:46 AM


All times are GMT -8. The time now is 11:18 AM.


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