The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniGraffle > OmniGraffle General
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Problem Using Scripting Bridge and OmniGraffle Thread Tools Search this Thread Display Modes
Hi -

I'm attempting to programatically create shapes, etc via an app I'm creating using Scripting Bridge, but I'm not having much luck.

I have the following code:

OmniGraffleDocument *document = [[[omnigraffle classForScriptingClass:@"document"] alloc] init];
[[omnigraffle documents] addObject:document];
SBElementArray *canvases = [document canvases];
OmniGraffleCanvas *mainCanvas = [canvases objectAtIndex:0];

// build the shape
NSDictionary *props = [NSDictionary dictionaryWithObjectsAndKeys:
		[NSArray arrayWithObjects:[NSNumber numberWithInt:20],[NSNumber numberWithInt:20]],@"origin",
		[NSArray arrayWithObjects:[NSNumber numberWithInt:100],[NSNumber numberWithInt:100]],@"size",
		[NSColor blackColor],@"stroke color"
OmniGraffleShape *shape = [[[[omnigraffle classForScriptingClass:@"shape"] alloc] initWithProperties:props] autorelease];
[[mainCanvas shapes] addObject:shape]

It successfully communicates to OmniGraffle, and creates a new document. But when it attempts to add the new shape to the canvas (the last line of code), it dies with the following in the debugger:

2009-12-02 16:43:13.242 TestApp[29013:813] Apple event returned an error.  Event = 'core'\'crel'{ 'kocl':'OGSh', 'insh':'insl'{ 'kobj':'obj '{ 'want':'OGSh', 'from':'obj '{ 'want':'OGWS', 'from':'obj '{ 'from':'null'(), 'want':'docu', 'form':'name', 'seld':'utxt'("Untitled 5") }, 'form':'indx', 'seld':1 }, 'form':'indx', 'seld':'abso'($206C6C61$) }, 'kpos':'end ' }, 'prdt':{  } }
Error info = {
    ErrorNumber = -10000;
Anyone have any experiences using Scripting Bridge and OmniGraffle?

The shape needs to be added to the graphics array of the layers array of the canvas:

OmniGraffleCanvas *mainCanvas = [canvases objectAtIndex:0];
OmniGraffleLayer *mainLayer = [[mainCanvas layers] objectAtIndex:0];
OmniGraffleShape *shape = [[[[omnigraffle classForScriptingClass:@"shape"] alloc] initWithProperties:props] autorelease];
[[mainLayer graphics] addObject:shape];

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripting bridge: crash when trying to get child tasks of a task amorya OmniFocus Extras 8 2013-11-10 05:00 AM
Scripting Bridge & NSColor pixel OmniGraffle General 0 2009-12-07 11:19 AM
Scripting Bridge & OOP namedStyles oopFan AppleScripting Omni Apps 0 2008-11-03 02:46 PM
Export issue / Modify the selection in a Document via AppleScript / Scripting Bridge Scifer_2008 OmniGraffle General 0 2008-10-08 06:06 AM
Problems using Scripting Bridge and OmniFocus 2shortplanks OmniFocus Extras 8 2008-08-09 09:35 PM

All times are GMT -8. The time now is 08:34 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.