Force refresh in AppleScript

From AppleScript (running outside OmniGraffle) I can change the visible attribute of layers. However, nothing visibly happens until I force a refresh somehow - tweaking the window size, scrolling, etc. Then the change is made clear.

Is there any way to make OmniGraffle update? Or is there a better way to change the visibility of layers - e.g. is there a command I can use rather than modifying the ‘visible’ property - which will cause OG to make the change and make it visible?


FWIW: so far my solution is to have an invisible graphic (no fill, no stroke) and use applescript to move it a few pixels. This seems to force the desired refresh

For the avoidance of cruft, does deleting this invisible object force a referee should?

Um “force a refresh”?


Since I want to run my script repeatedly (essentially this is animating a presentation by hiding various layers, switching to a canvas, then showing the layers in appropriate sequence/timing, switching to another canvas, etc…) I’m not doing that; the group is there, invisibly, just so that my script can tickle it, which reliably causes a refresh. I can see the appeal of adding/removing an object on the fly to avoid leaving cruft in the document, but I haven’t tried that.

Even better would be if there was some other action that AppleScript could initiate that caused a refresh without any change to the document itself - I’ve not found that yet. (Nearest I came was toggling the “canvas size is measured in pages” off and on again - however this causes a very visible adjustment, so is less desirable.)

So for now shifting an element is the least intrusive solution that I’ve found. If any has a better one, please do post it!

I have not used AppleScript with OmniGraffle. I suggest this only from a general perspective. Have you tried calling “tell application … to activate”?

Otherwise, I would argue this is a bug: When the visible state of a layer is toggled manually, the change occurs immediately. The same is not true using AppleScript. IOW, I would report it officially to OmniGroup.


Late to the thread, but I encountered this issue in a script I worked on earlier this week. YMMV, but in that script, inserting a delay 1.5 line allowed the screen to refresh. (A one-second delay did not.)

My memory is that suppressing screen draws was implemented in response to customer requests to increase script performance. Scripts originally updated the screen as they went, but that would cause the script to take longer to execute.

That said, this all happened something like a decade ago. Filed a note in our development database to revisit this and see if shortening or removing the delay is viable. Will add a link to this thread so any subsequent discussion or feedback can be incorporated. Hope this helps!

While updating the dev database, I ran across a similar item filed by one of our testers. Adding a delay line didn’t work for the test case filed there. However, there was a different workaround that seems like it might be helpful to post here in case it helps someone.

Rather than inserting a pause, you can try making a slight change to the zoom level, then backing that change to the zoom level out again:

	tell front window
		set OldZoom to zoom
		set zoom to zoom + 1
		set zoom to OldZoom
	end tell