Kam is right, here is a quick preview using the parser I mentioned in a previous post and the header file I generated using the following command: $ sdef /Applications/OmniGraffle\ Professional\ 5.app/ | sdp -fh --basename omni You will find the generated documentation, the parser code and the header file there: https://gist.github.com/1365637 I hope it helps. - Matt On Mon, Nov 14, 2011 at 8:19 PM, Kam Dahlin <haxie1@me.com> wrote:
You will need to create a shape object and then add it to the correct container. something like:
shape = OmniGraffleShape.alloc.init canvas.shapes.addObject shape
The different shape classes can be views by generating the OmniGraffle scriptingbridge header with: sdef /Path/To/OmniGraffle.app | sdp -fh -o /header/save/path -A --basename OmniGraffle
You may also want to generate the .bridgesupport file gen_bridge_metadata -c '-I/Path/To/OmniGraffle.h' -o /path/to/save/OmniGraffle.bridgesupport
And include that bridgsupport file in your script with load_bridge_support_file '/path/to/OmniGraffle.bridgesupport'
Matt has a great article on using ScriptingBridge with MacRuby: http://merbist.com/2010/01/17/controlling-itunes-with-macruby/
hth kam
On Nov 14, 2011, at 3:06 PM, Sophie wrote:
I am trying to automate OmniGraffle using MacRuby, and cannot figure out how to map Applescript to available MacRuby methods. For example, to add a shape takes roughly this Applescript:
tell application "OmniGraffle Professional" tell canvas of front window make new shape at end of graphics with properties {size: {10,80}, origin: {9,9}} end tell end tell
I can get a handle on the OmniGraffle application, on its document, canvas, etc. Can get a list of methods as below. But cannot find anything corresponding to the above "make new shape".
Is there any way to browse a MacRuby view of the scripting dictionary?
Thanks for any pointers!
Sophie
framework 'ScriptingBridge'
$omni = SBApplication.applicationWithBundleIdentifier("com.omnigroup.OmniGrafflePro")
$document = $omni.windows[0].document
$canvas = $omni.windows[0].canvas
$canvas.methods(true,true).sort
=> [:adjustsPages, :"assembleSubgraph:tableShape:", :bold, :canvasBackground, :canvasSize, :"childWithClass:code:keyForm:keyData:", :"childWithClass:code:keyForm:keyData:length:type:", :"childWithClass:code:keyForm:keyData:type:", :"childWithClass:code:keyForm:keyDesc:", :"closeSaving:savingIn:", :columnAlignment, :columnSpacing, :"connectTo:withProperties:", :context, :delete, :descriptionForSpecifier, :"duplicateTo:withProperties:", :elementArrayWithCode, :"elementWithCode:ID:", :"elementWithCode:atIndex:", :"elementWithCode:named:", :encodeWithCoder, :exists, :flipOver, :get, :graphics, :grid, :groups, :horizontalPages, :id, :"importCategories:frameworks:instanceVariableTypes:instanceVariables:interactionAllowed:mapping:methodSignatures:methods:outlineTemplate:protocols:", :"initWithApplication:specifier:", :"initWithClass:properties:data:", :initWithCoder, :"initWithContext:specifier:", :initWithData, :"initWithElementCode:properties:data:", :initWithProperties, :isRang eS pecifier, :italicize, :lastError, :layers, :layout, :layoutInfo, :lines, :moveTo, :objectClass, :pageAdjust, :pageSize, :positionAfter, :positionBefore, :properties, :"propertyWithClass:code:", :propertyWithCode, :qualifiedSpecifier, :qualify, :"replaceReplacement:ignoreCase:regexp:string:wholeWords:", :rowAlignment, :rowSpacing, :"saveAs:in:", :"sendEvent:id:format:", :"sendEvent:id:parameters:", :setAdjustsPages, :setCanvasSize, :setColumnAlignment, :setColumnSpacing, :setGrid, :setHorizontalPages, :setId, :setLastError, :setLayoutInfo, :setName, :setProperties, :setRowAlignment, :setRowSpacing, :setTo, :setVerticalPages, :shapes, :slideBy, :solids, :specifier, :specifierDescription, :subgraphs, :unbold, :underline, :unitalicize, :ununderline, :verticalPages]
On Nov 14, 2011, at 11:19 AM, macruby-devel-request@lists.macosforge.orgwrote:
Send MacRuby-devel mailing list submissions to macruby-devel@lists.macosforge.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel or, via email, send a message with subject or body 'help' to macruby-devel-request@lists.macosforge.org
You can reach the person managing the list at macruby-devel-owner@lists.macosforge.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of MacRuby-devel digest..."
Today's Topics:
1. Write your own version of Siri in MacRuby (Matt Aimonetti) 2. Re: MacRuby promise (Jean-Denis MUYS) 3. Re: MacRuby promise (Matt Aimonetti) 4. Re: MacRuby promise (Nat Brown)
----------------------------------------------------------------------
Message: 1 Date: Mon, 14 Nov 2011 13:57:10 -0300 From: Matt Aimonetti <mattaimonetti@gmail.com> To: "MacRuby development discussions." <macruby-devel@lists.macosforge.org> Subject: [MacRuby-devel] Write your own version of Siri in MacRuby Message-ID: <CAFGi+5fWTZ=faQCmhSokYvHWBE_Yae== fu+wsrr-FSH-ZicrPw@mail.gmail.com> Content-Type: text/plain; charset="utf-8"
I extracted an old demo I had made for RubyConf which shows how to use the voice recognizer feature of OS X to implement an app which could be the Siri equivalent for OS X: https://github.com/mattetti/MacRuby-Siri
The code is straight forward, the app runs in the top menu. Don't forget to turn on the voice recognition feature before testing the app.
- Matt