So, I still need some help... I need to be able to get the user data items for a shape. From the below info, you will see that I figured out how to set the user data. But it's useless to me unless I can query for it and compare it to known values.
Here is what I've come across... There is a cool utility into which you can paste AppleScript and generate the corresponding code in either Python, Ruby, or ObjC.
The utility is ASTranslate and can be found at
http://appscript.sourceforge.net/tools.html#astranslate
Just a sample of what is did for me... I selected the shape that I'd like to recreate and copy as AppleScript..
This copies the following apple script...
-----------------------------------
Code:
tell application "OmniGraffle Professional"
tell canvas of front window
make new shape at end of graphics with properties {user data: {hostName: "localhost"}, text placement: top, fill: no fill, origin: {121.000000, 354.500000}, autosizing: vertically only, size: {200.000000, 24.000000}, text: {text: "This Shape #2", text: "This Shape #2"}, draws shadow: false}
end tell
end tell
-----------------------------------
Paste this code in ASTranslator and translate a Ruby to get..
---------------------
Code:
app("OmniGraffle Professional 5").windows[1].canvas.make(:at => app.windows[1].canvas.graphics.end, :new => :shape, :with_properties => {
:origin => [121.000000, 354.500000],
:text => {
:text => "This Shape #2"
},
:text_placement => :top,
:draws_shadow => false,
:user_data => {
"hostname" => "localhost"
},
:autosizing => :vertically_only,
:fill => :no_fill,
:size => [200.000000, 24.000000]
})
--------------------
I still can't seem to figure out how to set user data after the object is created.
And I still need to figure out:
- How to update the user_data_item value.
- How to get the user_data_item name and value. This is needed so I can identify shapes with specific user data values.