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: Invert / toggle OmniGraffle selections (http://forums.omnigroup.com/showthread.php?t=22565)

RobTrew 2011-11-06 02:25 AM

Script: Invert / toggle OmniGraffle selections
 
Perhaps there is a way to do this through the GUI ?

In any case, here is a simple script.

After [B]Edit > Select > Similar Objects[/B], you could use it to alternate between selecting shapes and selecting lines.

Or, if you begin by selecting a particular sub-tree of your diagram, you could use the script to alternate between selecting that and selecting all the other graphics on the visible and unlocked layers of your canvas.

I find this useful for pulling a part of a diagram into the foreground, and pushing the rest of it into the background (by slightly graying it, for example).

[CODE]-- INVERT SELECTION
-- VER 0.2

-- Changes
-- Ver 0.2 If used when nothing is selected, should remember selection resulting from last use of this script.
-- NB selection memory only works when script is launched in environments in which properties persist
-- (e.g. will work if launched from a script menu, by not if launched from LaunchBar

property plstSeln : {}
property plstInvert : {}

on run
tell application id "OGfl"
tell front window
set plstSeln to selection
if plstSeln ≠ {} then
repeat with i from 1 to length of plstSeln
set item i of plstSeln to id of item i of plstSeln
end repeat

my InvertGraphicList(its canvas, plstSeln)
set selection to plstInvert
else
if plstInvert ≠ {} then set selection to plstInvert
end if
end tell
end tell
end run

on InvertGraphicList(oCanvas)
set plstInvert to {}
tell application id "OGfl"
set refLayers to a reference to (layers of oCanvas where its visible is true and its locked is false)
set lstAllID to my FlatList(id of graphics of refLayers)

repeat with i from 1 to length of lstAllID
set lngID to item i of lstAllID
if lngID is not in plstSeln then set end of plstInvert to graphic id lngID of oCanvas
end repeat
end tell
end InvertGraphicList

on FlatList(lst)
if class of lst is not list then
return {lst}
else if lst = {} then
return lst
else
return FlatList(item 1 of lst) & FlatList(rest of lst)
end if
end FlatList[/CODE]

RobTrew 2011-11-06 06:25 AM

If run when nothing is selected, ver 0.2 will try to remember the previous selection.


All times are GMT -8. The time now is 05:27 PM.

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