I found this online
and got most of it up and running, including updating the Swift syntax and renaming the OG object to their OmniGraffle6X names.
What I haven’t been able to do is figure out how to set a fillColor on a shape, or get text from the Shapes label ,or set text on the shapes Label. Can you help me out here?
Also any reference to code or documentation for how to do scripting using Swift would be very helpful.
Here’s my code. It crashes at the bottom of main.swift (it’s a command line tool project)
Any help would be appreciated. I want to get really good at this and will publish results on swiftest.io and github to help other folks.
I’m posting this to a Swift slack channel as well.
Whoops just updated the code.
OmniGraffle 6’s scripting API was developed for AppleScript, so most examples are in that language.
I don’t have any particular examples of scripting OmniGraffle from Swift.
Oh and I updated everything to OmniGraffle7 which I just bought. When I generated the API into the .h file it’s now without a 6 or 7 in the variable names.
More here: https://www.omnigroup.com/blog/looking-back-looking-ahead-2017-edition
cool, I’ll just follow and play. Should be fun.
I have to reacquaint myself with this…
Depending on what exactly you’re trying to accomplish, you might also check out GraphViz and the DOT format, which OmniGraffle imports.
just curious, fellow forumers…is there ANYONE out there besides me who is a Swift developer?
I am… answering after “only” 1 year.
Question: Why does it HAVE to be Swift? Yes, I understand the fashionable ness. But is there an integration or function need?
Not impossible to set up Swift as at the top of the thread, but the execution will be much slower than with running JS in the internal JSContext.
(Not because Swift is slow, but because the Swift+sdef route goes through the Apple Events interface - which certainly is slow, and which may now be less actively supported (for OmniGraffle) than the new interface to an embedded JS Context, which can be used on iOS as well as macOS).
Pff … takes two seconds – the good part of it is a small language – much smaller than Swift – once you have learned it you may even be in a position to discover whether you like using it or not :-)
Right; API boundary crossing tends to be expensive - and this one in particular is “the scenic route”.
Integrated into the engine - as OmniJS is - is bound to be quicker.