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

Magnets on lines Thread Tools Search this Thread Display Modes
Hi, I'm trying to draw a timing diagram across two parallel lines that are vertical (indicating time flows downwards). (cannot post http urls since im a forum newbie).

When I use the line tool, to connect the two lines horizontally, I can only use the head/tail to connect to attach the horizontal line head/tail.

How do I enable magnet points anywhere on the line? The connections in the inspection pane has the magnet point deselected. Do I need to manually create the magnet points with the magnet tool? Is there an easier way to do this?
A simple straight line can only have 2 magnet points at head and tail.

A multi-segment line, however, has a magnet at each segment boundary.

One approach might be:
  • View > Magnets
  • Hold down the shift key to constrain line drawing angles to multiples of 45 degrees
  • Make first click to start a straight line near the top of the canvas
  • Move down the canvas (keeping the shift key down) clicking once for every additional straight line segment
  • Dbl click to complete the line

You should now have a vertical line with magnets at various points.
Then, if you need more precision:
  • Select the multi-magnet line that you have created
  • Edit > Copy As > Applescript
  • Paste into the Applescript Editor
  • Inspect the code and edit the segment point coordinates to the exact positions that you want
  • To make the code runnable, edit the first line so that it reads: tell application id "OGfl"
  • Rerun the code to create a more precise line, and delete the rough original
Ah excellent idea.

Thank you!
And, of course, you can script various ways of adding one or more magnets to an existing vertical line.

sth like:

property pTitle : "Add Magnet(s) to vertical line"
property pVer : "0.03"

tell application id "OGfl"
	if (count of (windows where its id > 0)) < 1 then return
	tell front window
		set lstSeln to selection
		if length of lstSeln < 1 then return
		set oSeln to first item of lstSeln
		if class of oSeln ≠ line then return
		set lstPoints to point list of oSeln
		set {{XFirst, YFirst}, {XLast, YLast}} to {item 1 of lstPoints, item -1 of lstPoints}
		set strCoords to text returned of (display dialog ("Enter Y coords for new magnets on selected line
(comma-delimited if more than one)
Current range:
 " & YFirst as string) & " - " & YLast default answer "0" buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel" with title pTitle & "  ver. " & pVer)
		set lstNewY to my Commas2List(strCoords)
		repeat with i from 1 to length of lstNewY
			set item i of lstNewY to {XFirst, item i of lstNewY}
		end repeat
		set point list of oSeln to my SortVerticalPoints(lstPoints & lstNewY)
		set magnets visible of its document to true
	end tell
end tell

on Commas2List(strCoords)
	set {dlm, my text item delimiters} to {my text item delimiters, ","}
	set lstNum to {}
	repeat with oPart in (text items of strCoords)
			set end of lstNum to (oPart as number)
		on error
			display dialog oPart & " could not be interpreted as a number" buttons {"OK"} default button "OK" with title pTitle & "  ver. " & pVer
		end try
	end repeat
	set my text item delimiters to dlm
end Commas2List

on SortVerticalPoints(lstPoints)
	set strLines to my NumList2Lines(lstPoints)
	set strSorted to do shell script "echo " & quoted form of strLines & " | sort -k 2 -n"
	set lstPoints to my Lines2NumList(strSorted)
end SortVerticalPoints

on NumList2Lines(lst)
	set {dlm, my text item delimiters} to {my text item delimiters, tab}
	repeat with i from 1 to length of lst
		set item i of lst to item i of lst as text
	end repeat
	set my text item delimiters to linefeed
	set strLines to (lst as text)
	set my text item delimiters to dlm
end NumList2Lines

on Lines2NumList(strLines)
	set lstLines to paragraphs of strLines
	set {dlm, my text item delimiters} to {my text item delimiters, tab}
	repeat with i from 1 to length of lstLines
		set lstNums to text items of item i of lstLines
		repeat with j from 1 to length of lstNums
			set item j of lstNums to item j of lstNums as number
		end repeat
		set item i of lstLines to lstNums
	end repeat
	set my text item delimiters to dlm
end Lines2NumList
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2012-07-15 at 22.43.06.png
Views:	503
Size:	39.7 KB
ID:	2468  

Last edited by RobTrew; 2012-07-15 at 03:36 PM.. Reason: Ver 0.02 allows for list of comma-delimited vertical positions for new magnets
Finally, in principle you should be able to add these junctions/magnets by CMD-clicking at new points on the line.

Good enough for approximate work, but for some reason it seems to generate slight horizontal inaccuracies on my system (holding down the SHIFT key should reduce them)

(If you select a magnet node, and kept the SHIFT key down, you should be able to drag the node to a new vertical position without introducing a kink into the line)


Last edited by RobTrew; 2012-07-15 at 10:25 AM..

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to control and lock lines to magnets deep inside objects mcdonald OmniGraffle General 0 2012-10-06 09:01 AM
fixing lines to magnets pjb OmniGraffle General 3 2011-07-10 02:20 AM
placing magnets and not affect other lines noahwallach OmniGraffle General 3 2009-08-13 04:06 PM
Fine control of magnets and connecting lines louabill OmniGraffle General 1 2006-12-04 01:32 PM
Controlling angle of lines into magnets... how? glawrie OmniGraffle General 3 2006-06-23 04:27 PM

All times are GMT -8. The time now is 04:47 AM.

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