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

sth like:

Code:
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
		
		-- READ THE EXISTING POINT LIST FROM ANY SELECTED LINE
		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}
		
		
		-- PROMPT USER FOR NEW VERTICAL COORDINATES (comma delimited)
		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
		
		-- ADD NEW MAGNETS AT SPECIFIED POSITIONS
		set point list of oSeln to my SortVerticalPoints(lstPoints & lstNewY)
		
		--AND ENSURE THAT MAGNETS ARE VISIBLE
		set magnets visible of its document to true
	end tell
	activate
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)
		try
			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
	lstNum
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
	strLines
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
	lstLines
end Lines2NumList
--
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2012-07-15 at 22.43.06.png
Views:	288
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