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

 
Order of creating shapes within a tell canvas Thread Tools Search this Thread Display Modes
I'm using a shell script to generate applescript to produce a number of figures. The figures contain filled shapes which must be logically in front of other shapes and lines. I'm relying on the filling property of front shapes to hide the lines and so forth that are behind them.

For each figure, the script puts out a “make new document... tell canvas...” followed by a number of “make new line...” and “make new shape” commands.

What I've observed is that when this script is executed (by osascript), the first-drawn shapes and lines end up in front. That is, in order to get the precedence I need, I have to reverse the order one would use if doing it by hand, and put out what I want to be in front of everything first, and what I want to be behind everything last. It's not a big deal, but I did need to scratch my head a bit to figure out what was going on.

My question is: is this going to stay this way (i.e., it's a feature, not a bug), or is this something that will be corrected at some point (i.e., I'll need to be ready to change my scripts)?

Greg
 
The devil is in the details here, and you haven't really provided them. Can we see the entire statement creating the new shapes?
 
The following is a reduced illustrative example. It's a hierarchy of bar graphs. Note that the narrower bars must come in front of the wider ones, and that the bars must come in front of the guide lines (the widest bar is that very short one rising slightly above the baseline, almost completely hidden by the two big intermediate ones). In the script fragment, it is written last of all the bars, right before the guidelines are drawn. If you copy the script fragment to the clipboard, you can see the graph with “pbaste | osascript” in Terminal.
Code:
tell application id "com.omnigroup.OmniGrafflePro"
activate
close front window
make new document with properties {template: "Blank"}
tell canvas of front window
make new shape at end of graphics with properties {fill: solid fill, fill color: {1, 1, 1, 1}, draws shadow: false, size: {46.7027027027027024, 4.87735578}, origin: {326.91891891891892, 211.12264422}}
make new shape at end of graphics with properties {fill: solid fill, fill color: {1, 1, 1, 1}, draws shadow: false, size: {46.7027027027027032, 60.1554228}, origin: {256.864864864864865, 216}}
make new shape at end of graphics with properties {fill: solid fill, fill color: {1, 1, 1, 1}, draws shadow: false, size: {46.7027027027027026, 13.7178294}, origin: {163.45945945945946, 216}}
make new shape at end of graphics with properties {fill: solid fill, fill color: {1, 1, 1, 1}, draws shadow: false, size: {46.7027027027027028, 66.0924}, origin: {93.4054054054054056, 216}}
make new shape at end of graphics with properties {fill: solid fill, fill color: {1, 1, 1, 1}, draws shadow: false, size: {140.108108108108108, 82.003416}, origin: {245.18918918918919, 133.996584}}
make new shape at end of graphics with properties {fill: solid fill, fill color: {1, 1, 1, 1}, draws shadow: false, size: {140.108108108108108, 80.149344}, origin: {81.7297297297297299, 135.850656}}
make new shape at end of graphics with properties {fill: solid fill, fill color: {1, 1, 1, 1}, draws shadow: false, size: {326.91891891891892, 2.52162636}, origin: {70.0540540540540542, 213.47837364}}
make new line at end of graphics with properties {point list: {{35.0270270270270271, 216}, {432.000000000000001, 216}}, tail scale: 0.5, head scale: 0.5}
make new line at end of graphics with properties {point list: {{35.0270270270270271, 414}, {35.0270270270270271, 18}}, tail scale: 0.5, head scale: 0.5}
make new line at end of graphics with properties {point list: {{35.0270270270270271, 414}, {432.000000000000001, 414}}, tail scale: 0.5, head scale: 0.5, stroke pattern: 18}
make new shape at end of graphics with properties {side padding: 0, fill: no fill, draws stroke: false, draws shadow: false, autosizing: clip, size: {20, 10}, text: {text: "***", size: 14, alignment: right, font: "Helvetica", text: "***"}, origin: {10.6756756756756757, 411}, vertical padding: 0}
make new line at end of graphics with properties {point list: {{35.0270270270270271, 348}, {432.000000000000001, 348}}, tail scale: 0.5, head scale: 0.5, stroke pattern: 18}
make new shape at end of graphics with properties {side padding: 0, fill: no fill, draws stroke: false, draws shadow: false, autosizing: clip, size: {20, 10}, text: {text: "**", size: 14, alignment: right, font: "Helvetica", text: "**"}, origin: {10.6756756756756757, 345}, vertical padding: 0}
make new line at end of graphics with properties {point list: {{35.0270270270270271, 301.86798}, {432.000000000000001, 301.86798}}, tail scale: 0.5, head scale: 0.5, stroke pattern: 18}
make new shape at end of graphics with properties {side padding: 0, fill: no fill, draws stroke: false, draws shadow: false, autosizing: clip, size: {20, 10}, text: {text: "*", size: 14, alignment: right, font: "Helvetica", text: "*"}, origin: {10.6756756756756757, 298.86798}, vertical padding: 0}
make new line at end of graphics with properties {point list: {{35.0270270270270271, 282}, {432.000000000000001, 282}}, tail scale: 0.5, head scale: 0.5, stroke pattern: 18}
make new shape at end of graphics with properties {side padding: 0, fill: no fill, draws stroke: false, draws shadow: false, autosizing: clip, size: {20, 10}, text: {text: "*", size: 14, alignment: right, font: "Helvetica", text: "*"}, origin: {10.6756756756756757, 279}, vertical padding: 0}
make new line at end of graphics with properties {point list: {{35.0270270270270271, 150}, {432.000000000000001, 150}}, tail scale: 0.5, head scale: 0.5, stroke pattern: 18}
make new shape at end of graphics with properties {side padding: 0, fill: no fill, draws stroke: false, draws shadow: false, autosizing: clip, size: {20, 10}, text: {text: "*", size: 14, alignment: right, font: "Helvetica", text: "*"}, origin: {10.6756756756756757, 147}, vertical padding: 0}
make new line at end of graphics with properties {point list: {{35.0270270270270271, 130.13202}, {432.000000000000001, 130.13202}}, tail scale: 0.5, head scale: 0.5, stroke pattern: 18}
make new shape at end of graphics with properties {side padding: 0, fill: no fill, draws stroke: false, draws shadow: false, autosizing: clip, size: {20, 10}, text: {text: "*", size: 14, alignment: right, font: "Helvetica", text: "*"}, origin: {10.6756756756756757, 127.13202}, vertical padding: 0}
make new line at end of graphics with properties {point list: {{35.0270270270270271, 84}, {432.000000000000001, 84}}, tail scale: 0.5, head scale: 0.5, stroke pattern: 18}
make new shape at end of graphics with properties {side padding: 0, fill: no fill, draws stroke: false, draws shadow: false, autosizing: clip, size: {20, 10}, text: {text: "**", size: 14, alignment: right, font: "Helvetica", text: "**"}, origin: {10.6756756756756757, 81}, vertical padding: 0}
make new line at end of graphics with properties {point list: {{35.0270270270270271, 18}, {432.000000000000001, 18}}, tail scale: 0.5, head scale: 0.5, stroke pattern: 18}
make new shape at end of graphics with properties {side padding: 0, fill: no fill, draws stroke: false, draws shadow: false, autosizing: clip, size: {20, 10}, text: {text: "***", size: 14, alignment: right, font: "Helvetica", text: "***"}, origin: {10.6756756756756757, 15}, vertical padding: 0}
end tell
end tell

Last edited by gshenaut; 2013-02-27 at 02:57 PM..
 
As I suspected — you are doing "make new shape at end of graphics" (emphasis mine). That puts your new shape behind everything drawn so far. You might prefer "make new shape at front of graphics" to have the last thing added be the frontmost object.

I'm glad I didn't have anything important in that frontmost OmniGraffle window when I ran your code! :-)
 
Well, I admit that makes sense. I used “at end of graphics” because that is what I have always seen in applescripts for OG. I thought it was just syntactic sugar for adding a new element to the list. I had no idea that variation was even possible. Are there other things you can plug in in “at X of graphics” ? (Note that “in front of” and “behind” would have been more mnemonic.)

P.S. As for the close front window, that's because this is part of a lengthy series of figures that are saved in separate files; it is just easier to close the window before each one.

Update:
P.P.S.
Thanks, by the way.

Last edited by gshenaut; 2013-02-27 at 02:58 PM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating single header and footer per canvas bullwrinkle OmniGraffle General 0 2012-05-02 10:49 AM
Creating connecting shapes claumann OmniGraffle General 0 2010-07-05 01:24 PM
Creating 3D shapes nigelbeatty OmniGraffle General 1 2009-08-27 04:18 AM
Outline sidebar--will its order affect canvas? santra OmniGraffle General 3 2008-11-07 03:48 AM
How do I iterate over ALL shapes in a canvas? supertwang@yahoo.com OmniGraffle Extras 1 2007-08-20 09:59 AM


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


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