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.
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.
Code:
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" activate 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