The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniGraffle General (http://forums.omnigroup.com/forumdisplay.php?f=10)
-   -   Applescript: which shape properties can be set via a dictionary? (http://forums.omnigroup.com/showthread.php?t=27144)

Sophie 2012-11-22 12:07 PM

Applescript: which shape properties can be set via a dictionary?
 
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
[/CODE]
Is there some rule & reason about which properties can be set this way?

RobTrew 2012-11-23 12:59 AM

In principle there should be no such limitations, and the very useful [B]Copy As Applescript[/B] 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[/CODE]

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.

[COLOR="White"]--[/COLOR]

RobTrew 2012-11-23 01:14 AM

[QUOTE=RobTrew;117723]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.[/QUOTE]

Ah… no, it hasn't …

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

Always worth adding to the count of formal reports on these cherished old friends through [B]Help > Send Feedback[/B]

Sophie 2012-11-23 06:49 AM

[QUOTE=RobTrew;117723]

[CODE]tell application id "OGfl"
tell canvas of front window
[B]make new shape[/B] 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[/CODE]

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.

[COLOR="White"]--[/COLOR][/QUOTE]

If you change your [B]make new shape[/B] 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:
[INDENT]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[/INDENT]
On the whole it does not look like setting multiple properties of an [B]existing[/B] shape via a dictionary is supported. Could someone from Omni confirm / shed some light?

Thanks!

RobTrew 2012-11-23 08:17 AM

Got it. I missed the word [I]existing[/I] in your post.

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


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

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