View Single Post
I totally understand your frustration. I pulled out what little hair I had left, trying to work with user data.
Just when I got the script to work with some sample data, I did a real test with a fair amount of data and performance was in the 'days' rather than minutes which I expected.
As a result all this code I'm sharing is obsolete, as I've converted to ruby and rb-appscript.

Example of making adding user data to a shape (grouped shapes in this case)
Quote:
set groupedAppShapes to assemble listOfGraphicsToGroup
tell groupedAppShapes
make new user data item with properties {name:"ObjectType", value:"Application Shape"}
end tell
Example of getting the user data from a graphic and inspecting that data. Note that this is just the opening part of a very long repeat loop, so you will seen some blocks are not ended or closed as didn't paste the entire block of code.
Quote:
-- get a graphic to work with...
repeat with clientAppGraphic in (get every graphic)
-- set a reference to that user data of the graphic
-- Yes this makes for longer code, but makes it easier to work with, in my opinion.
set clientAppGraphicUserData to the user data of clientAppGraphic
-- I couldn't figure out how to do any fancy 'where / whos' user data contains logic, so I use a simple 'if' condition to test for what I want...
if clientAppGraphicUserData contains {|ObjectType|:"Application Shape"} then
log "this is a application shape"
-- Now that I've found the graphic with the user data I was looking for, I set some variables using additional user data keys
set thisClientAppName to get |appName| of clientAppGraphicUserData
set thisRedundacnyRole to get |redundancyRole| of clientAppGraphicUserData