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

 
Script: Copy and past line from OmniGraffle to OmniGraphSketcher Thread Tools Search this Thread Display Modes
If you copy a line in OmniGraffle (with Cmd C), you will find that you can not paste it into OmniGraphSketcher.

If, however, you select a line in OmniGraffle, and copy it by running this script, you will find that you can then paste it's set of points into OmniGraphSketcher for quick decoration and axis-framing.

(Places line in clipboard as a sequence of point coordinates - could also be pasted into something like Excel)

Code:
-- Ver .03 (Slightly faster)

-- Copy coordinates of selected OmniGraffle line into Clipboard
-- (In form that can be pasted into OmniGraphSketcher, Excel, etc)


on run
	tell application id "OGfl"
		tell front window
			set lstSeln to selection
			set blnFound to false
			repeat with oSeln in lstSeln
				if class of oSeln is line then
					set blnFound to true
					exit repeat
				end if
			end repeat
		end tell
		
		if blnFound then
			set lstData to points of oSeln
			set {{rxMin, rxMax}, {ryMin, ryMax}} to my GetRanges(lstData)
			set {rOriginX, rOriginY} to {rxMin + ((rxMax - rxMin) / 2), ryMin + ((ryMax - ryMin) / 2)}
		else
			return
		end if
		
		set strClip to ""
		set {dlm, my text item delimiters} to {my text item delimiters, tab}
		repeat with i from 1 to length of lstData
			set {rX, rY} to item i of lstData
			set item i of lstData to ({(rX - rOriginX), -(rY - rOriginY)} as string)
		end repeat
		set my text item delimiters to return
		set the clipboard to (lstData as string)
		set my text item delimiters to dlm
	end tell
end run


on GetRanges(lstData)
	set rHigh to 2 ^ 16
	set {rxMin, rxMax, ryMin, ryMax} to {rHigh, 0, rHigh, 0}
	
	repeat with oPoint in lstData
		set {rX, rY} to oPoint
		if rX < rxMin then set rxMin to rX
		if rX > rxMax then set rxMax to rX
		
		if rY < ryMin then set ryMin to rY
		if rY > ryMax then set ryMax to rY
	end repeat
	{{rxMin, rxMax}, {ryMin, ryMax}}
end GetRanges
--

Last edited by RobTrew; 2011-11-14 at 11:53 AM.. Reason: Typo in title :-)
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to copy columns (and any selected rows) to new doc RobTrew OmniOutliner 3 for Mac 0 2010-06-07 02:47 AM
Adapted script to copy a spreadsheet into OmniOutliner scooby OmniOutliner 3 for Mac 0 2009-07-12 10:07 AM
Copy column script DerekM OmniOutliner 3 for Mac 8 2009-01-27 01:40 PM


All times are GMT -8. The time now is 07:43 AM.


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