The Omni Group Forums

The Omni Group Forums (
-   AppleScripting Omni Apps (
-   -   Non-deterministic behaviour driving me insane (

cyleigh 2012-05-07 04:40 PM

Non-deterministic behaviour driving me insane
I have a script that is updating a stencil, and is run multiple time, with different text on the shape each time. My problem seems to be, that the first two (or sometimes three) executions of the script will reflect the updated stencil immediately in the GUI of OG, but later executions will require a quit/restart in order for the changes to be visible.

Restarting OG after each update is obviously going to be a pain (especially as the script will ultimately be executed from inside a java application that is slow enough as it is..), so I am hoping that there is just something I don't understand at play here.

property stencilName : "experiments_Accidents.gstencil"
property appSupportPath : path to application support from user domain
property stencilSaveName : ((appSupportPath as text) & "OmniGraffle:Stencils:" & stencilName)
on determineOrigin(myDocument)
set xpos to 18
set ypos to 15
tell application "OmniGraffle Professional 5"
tell front canvas of myDocument
set myAccidents to graphics whose value of user data item "myKind" is "Accident"
repeat with _a in myAccidents
set org to origin of _a
set y0 to item 2 of org
if (y0 > ypos) then set ypos to y0
end repeat
set i to (length of myAccidents) + 1
if (i > 1) then
set xpos to xpos + ((i - 1) mod 6) * (54.0 + 5.0)
if (i mod 6 is equal to 1) then
set ypos to ypos + 54.0 + 5.0
set xpos to 18
end if
end if
end tell
end tell
return {xpos, ypos}
end determineOrigin
on run
tell application "OmniGraffle Professional 5"
end tell
tell application "OmniGraffle Professional 5"
set myDocument to open alias (stencilSaveName as text)
tell front canvas of myDocument
make new shape at end of graphics with properties {user data:{myKind:"Accident", myName:"experiments.A1", myIAV:"0#0", myKey:"experiments#0#0 "}, size:{54.0, 54.0}, thickness:2, stroke cap:butt, magnets:{{0, 1}, {0, -1}, {1, 0}, {-1, 0}}, vertical padding:0, origin:my determineOrigin(myDocument), rank group:-1, fill color:{1.0, 0.0, 0.0}, text:{text:"A1", alignment:center}, gradient color:{0.666667, 0.666667, 0.666667}, shadow vector:{-2.0, 2.0}}
close myDocument saving yes
end tell
end tell
end run[/CODE]

whpalmer4 2012-05-07 05:57 PM

You might try slightly adjusting the zoom factor after each invocation. RobTrew has reported that doing so gives OmniGraffle the necessary kick in the pants to redraw (we'd all be in agreement that it should not be necessary to use such kludges!)

Be sure to send in a bug report with Send Feedback, that'll probably boost the number of "votes" for a bug fix by 50%...

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

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