The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniGraffle General (http://forums.omnigroup.com/forumdisplay.php?f=10)
-   -   Script: Copy and past line from OmniGraffle to OmniGraphSketcher (http://forums.omnigroup.com/showthread.php?t=22622)

RobTrew 2011-11-12 03:08 PM

Script: Copy and paste line from OmniGraffle to OmniGraphSketcher
 
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
[/CODE]

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


All times are GMT -8. The time now is 08:00 AM.

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