Get Name of object

Is there anyway from appescript to get the name of an omnigraffle graphic object? What I am after is the text in the Name filed in the ‘Type’ inspector

name of g -- returns 'Rectangle', where g is a graphic object

Andrew

I’d like to do this too.

One way to explore the accessible properties of a shape or line on the canvas is to click-select it, and then run a piece of code like this in Script Editor:

If you look for the name (and perhaps note) that you have given to the shape (in this case “Jiaozi tang” and “boil vigorously”, you will find that the shape has the properties:

user name
note

So in AppleScript we can write something like:

tell application id "com.omnigroup.OmniGraffle6"
	set s to (selection of front window)
	set g to item 1 of s
	
	set strUserName to user name of g
	set strNotes to notes of g
	
	return {strUserName, strNotes}
end tell

Note that a couple of posts related to the eleven months that elapsed without any answer to this question have been inappropriately kicked into the long grass of the Meta forum by Brian Covey – manager of the support service which is responsible for the dereliction of this forum, in which user queries have consistently been ignored for months or even a year at a time.

Equally, in Apple’s newer JavaScript for Applications (which is assisted in El Capitan by Safari’s debugger), and which might be more familiar to people who do any web work, you could write:

(function () {
    'use strict';

    var og = Application('Omnigraffle'),
        wins = og.windows(),
        w = wins.length ? wins[0] : undefined,
        selected = w ? w.selection() : [],
        g = selected && selected.length ? selected[0] : undefined;

    return g ? {
        name: g.userName(),
        notes: g.notes()
    } : undefined;
})();

( but notice that you would need to change the Language indicator at the top left of the Script Editor screen from AppleScript to JavaScript )