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 Today's Posts

 
Applescript: which shape properties can be set via a dictionary? Thread Tools Search this Thread Display Modes
I am trying to set the properties of an existing shape by passing a dictionary of name : value pairs, following RobTrew's advice. But it seems hit-or-miss as some properties (e.g. thickness, draws shadow) change properly, while others (e.g. text, gradient color) do not change.

Code:
tell application id "OGfl"
	set lstSeln to selection of front window
	set oShape to item 1 of lstSeln
	tell canvas of front window
		set properties of oShape to {prop1: val1, prop2: val2, ....}
	end tell
end tell
Is there some rule & reason about which properties can be set this way?
 
In principle there should be no such limitations, and the very useful Copy As Applescript function should give an idea of the right syntax (subject to the perennial bug that Copy As Applescript generates code which doesn't in fact run, because it gets the "Tell Application" line wrong, at least for OG professional).

Code:
tell application id "OGfl"
	tell canvas of front window
		make new shape at end of graphics with properties {corner radius:5, fill:linear fill, draws stroke:false, autosizing:clip, size:{90.0, 90.0}, text:{{text:"This text is ", alignment:center}, {text:"partially", alignment:center, font:"Helvetica-Bold"}, {text:" bolded", alignment:center}}, origin:{358.0, 223.000002}, gradient color:{0.666667, 0.177494, 0.193412}, magnets:{{0, 1}, {0, -1}}, vertical padding:0, fill color:{1.0, 0.610458, 0.121713}}
	end tell
end tell
There used to be a bug in scripted changes to text properties which required a forced refresh (by nudging zoom level) before you could see the results, but my impression was that that has now been addressed.

--

Last edited by RobTrew; 2012-11-23 at 03:25 AM..
 
Quote:
Originally Posted by RobTrew View Post
There used to be a long-standing bug in scripted changes to text properties which required a forced refresh (by nudging zoom level) before you could see the results, but my impression was that that has now been addressed.
Ah… no, it hasn't …

For a little light entertainment:
http://forums.omnigroup.com/showthread.php?t=23442

Always worth adding to the count of formal reports on these cherished old friends through Help > Send Feedback
 
Quote:
Originally Posted by RobTrew View Post

Code:
tell application id "OGfl"
	tell canvas of front window
		make new shape at end of graphics with properties {corner radius:5, fill:linear fill, draws stroke:false, autosizing:clip, size:{90.0, 90.0}, text:{{text:"This text is ", alignment:center}, {text:"partially", alignment:center, font:"Helvetica-Bold"}, {text:" bolded", alignment:center}}, origin:{358.0, 223.000002}, gradient color:{0.666667, 0.177494, 0.193412}, magnets:{{0, 1}, {0, -1}}, vertical padding:0, fill color:{1.0, 0.610458, 0.121713}}
	end tell
end tell
There used to be a bug in scripted changes to text properties which required a forced refresh (by nudging zoom level) before you could see the results, but my impression was that that has now been addressed.

--
If you change your make new shape to use an existing shape, and try to set it's properties with a dictionary, you will find a ton of properties will not work (not visually, nor even changing the underlying data, I think). From the properties I have tried so far, I have had trouble with all of the following:
name, text, stroke_cap, autosizing, fill, fill_color, blend_color, gradient_color, gradient_angle, blend_fraction, side_padding, vertical_padding, textRotation, head_type, tail_type, head_scale, tail_scale, line_type
On the whole it does not look like setting multiple properties of an existing shape via a dictionary is supported. Could someone from Omni confirm / shed some light?

Thanks!
 
Got it. I missed the word existing in your post.

Busy OmniPeople don't always catch the forum postings - Help > Send Feedback will certainly get a response.
 
 




Similar Threads
Thread Thread Starter Forum Replies Last Post
Applescript: set multiple shape properties in 1 call? Sophie OmniGraffle General 5 2012-11-18 07:30 AM
Set a bunch of shape properties in one call? Sophie OmniGraffle General 0 2012-11-07 10:28 PM
applescript dictionary version jamesafoster OmniFocus Extras 1 2009-10-29 02:46 AM
Protect shape properties mattydj OmniGraffle Extras 1 2009-10-22 04:43 PM
Understanding Applescript Dictionary tomrowan OmniGraffle Extras 2 2007-01-25 05:29 PM


All times are GMT -8. The time now is 03:24 PM.


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