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 > OmniGraffle > OmniGraffle General
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Setting Canvas Background using AppleScript Thread Tools Search this Thread Display Modes
Hello all, new user here. I am trying to do some automation using Applescript to generate Graffle graphics, and I want to see about changing the canvas color. I thought it would be something like:

Code:
set properties of first canvas of first document to {canvasSize: {500,500}, canvasBackground: {.5, .5, .5}}
But that throws an AppleEvent handler failed error. Alternatively, I tried:

Code:
set properties of first canvas of first document to {canvasSize: {500,500}, fill color: {.5, .5, .5}}
Which doesn't fail but has no effect.

Thanks in advance!
 
The Applescript dictionary for OG,

(File > Open Dictionary in Applescript Editor)

shows that the canvasBackground property is read-only (the access is get but not set) (and has the type of an OG solid, incidentally).

Another approach would be to script the creation of a colored rectangle of the size you want. (On a lower layer than your other graphics, and perhaps with its locked property set to true).

--
 
Thanks for the answer RobTrew. That explains my trouble. I had been looking in the Applescript Dictionary, but I am also new to Applescript and didn't realize what the 'r/o' meant. Forgive my ignorance. I'm surprised it would be read only when the option is available to set the canvas color when you do it manually. Is there a way you would recommend to make a shape the size of the whole canvas? When I set the shape size to the same size I defined my canvas as the canvas is always bigger. Thanks.
 
While the canvasBackground object itself is r/o, once you have read a reference to it, you can set its properties through that reference.

Code:
tell application id "OGfl"
	tell first canvas of front document
		set canvasSize to {500, 500}
		tell canvasBackground
			set fill to solid fill
			set fill color to {0.5, 0.5, 0.5}
		end tell
	end tell
end tell
 
Thanks for all your help! This is exactly what I needed.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



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


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