View Single Post
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:

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",
		FALSE,@"drawsShadow",
		TRUE,@"drawsStroke",
		@"ShapeName","name",
		[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:

Code:
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?

Thanks!
--Eric