The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > Developer > AppleScripting Omni Apps
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Non-deterministic behaviour driving me insane Thread Tools Search this Thread Display Modes
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.

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
 
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%...
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Repeating tasks driving me nuts CarlLofgren OmniFocus 1 for Mac 6 2013-04-03 06:50 AM
OmniGraffle is driving me crazy! lrawlins OmniGraffle General 2 2012-10-16 08:52 AM
Scaling / Resizing is driving me crazy omnimighty OmniGraffle General 1 2011-07-15 02:29 PM
Am I going insane? cyleigh OmniFocus 1 for Mac 2 2008-06-12 03:08 PM


All times are GMT -8. The time now is 12:27 AM.


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