How to get all the properties of the graphic

In the actual use process, I want to know all the attributes of a graphic, what should I do?

Anyone know? thank you

    if (document.windows[0].selection.graphics.length != 1) {
    title = "SELECTION ERROR"
    message = "Please select a single graphic."
    new Alert(title, message).show(function (result) { })
} else {
    cnvs = document.windows[0].selection.canvas
    graphic = document.windows[0].selection.graphics[0]

    // graphic  How to get all the properties of it?

Not quite the same, but here is JXA snippet (for use in Script Editor, Keyboard Maestro etc), which displays an OG7-copied clipboard as a human-readable property list:

(() => {
    'use strict';

    ObjC.import('AppKit');

    // Left :: a -> Either a b
    const Left = x => ({
        type: 'Either',
        Left: x
    });

    // Right :: b -> Either a b
    const Right = x => ({
        type: 'Either',
        Right: x
    });

    // bindLR (>>=) :: Either a -> (a -> Either b) -> Either b
    const bindLR = (m, mf) =>
        m.Right !== undefined ? (
            mf(m.Right)
        ) : m;

    // elem :: Eq a => a -> [a] -> Bool
    const elem = (x, xs) => xs.includes(x);

    // isLeft :: Either a b -> Bool
    const isLeft = lr =>
        lr.type === 'Either' && lr.Left !== undefined;

    // String copied to general pasteboard
    // copyText :: String -> IO Bool
    const copyText = s => {
        const pb = $.NSPasteboard.generalPasteboard;
        return (
            pb.clearContents,
            pb.setStringForType(
                $(s),
                $.NSPasteboardTypeString
            )
        );
    };
    
    // standardSEAdditions :: () -> Application
    const standardSEAdditions = () =>
      Object.assign(Application('System Events'), {
        includeStandardAdditions: true
      });

    // MAIN ------------------------------------------------------------------
    const
        ogType = 'com.omnigroup.OmniGraffle.GraphicType',
        pBoard = $.NSPasteboard.generalPasteboard;

    const lrResult = bindLR(
        elem(ogType,
            ObjC.deepUnwrap(pBoard.pasteboardItems.js[0].types)
        ) ? Right(
            JSON.stringify(
                ObjC.deepUnwrap(
                    pBoard.propertyListForType(ogType)
                ),
                null, 2
            )
        ) : Left('OG7 graphics not found on clipboard'),
        strJSON => {
            const sa = standardSEAdditions();
            copyText(strJSON);
            sa.activate();
            sa.displayDialog(strJSON);
            return Right('Clipboard now contains JSON-encoded OG7 graphics')
        }
    );

    return lrResult.Right || lrResult.Left
})();

Or, of course, there is Edit > Copy As JavaScript, tho it yields a curiously flattened result which I personally don’t find all that useful.

1 Like

Wow, it is available, thank you very much, happy holidays.

1 Like