The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   AppleScripting Omni Apps (http://forums.omnigroup.com/forumdisplay.php?f=46)
-   -   Bringing graphic objects to front in OmniGraffle (http://forums.omnigroup.com/showthread.php?t=23215)

mediaczar 2012-01-14 12:43 PM

Bringing graphic objects to front in OmniGraffle
 
I can't find a means of bringing a selected graphic object to the front (as per the "Arrange > Bring to Front" Command)

Or indeed, sending it backwards.

Here's the issue. I'm using the following function to create links between nodes in a network, and the labels are (for whatever reason) drawing behind the connectors. I'd like to bring the label object forward, and can't.

[B]Caveat:[/B] I'm new to AppleScript. It seems horribly undocumented.


[CODE]on linkCircle(fromTag, toTag)
tell application "OmniGraffle Professional 5"
tell canvas of front window

set fromCircle to the first solid whose tag = fromTag

set toCircle to the first solid whose tag = toTag

tell fromCircle
set newConnection to connect to toCircle with ¬
properties {line type:orthogonal}
end tell

set newLabel to make new shape at end of graphics ¬
with properties {draws shadow:false, autosizing:full, ¬
text:{text:"hello world", alignment:center}, ¬
draws stroke:false}

set labelConnection of newLabel to newConnection
end tell
end tell
end linkCircle[/CODE]

RobTrew 2012-01-14 08:24 PM

[QUOTE=mediaczar;106216]I can't find a means of bringing a selected graphic object to the front (as per the "Arrange > Bring to Front" Command)[/QUOTE]

This is encoded in the order of the [I]graphics[/I] collection of the canvas, so:

[CODE]set newLabel to make new shape [B]at beginning[/B] of graphics ¬
with properties ¬
{draws shadow:false, autosizing:full, text:{text:"hello world", alignment:center}, draws stroke:false}[/CODE]

RobTrew 2012-01-14 08:38 PM

Or, more generally:

[CODE]on run
tell application id "OGfl"
tell front window
set refGraphics to a reference to graphics of its canvas
set lstSeln to selection
repeat with oSeln in lstSeln
my BringToFront(oSeln, refGraphics)
end repeat
end tell
end tell
end run

on BringToFront(oGraphic, refGraphics)
move oGraphic to beginning of refGraphics
end BringToFront

on SendToBack(oGraphic, refGraphics)
move oGraphic to end of refGraphics
end SendToBack[/CODE]

mediaczar 2012-01-15 03:11 AM

Rob - many thanks. That's not only answered my question, but given me some insight into the whole approach. Was stumbling around in the dark before...

Thank you :)


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

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