Problem Using Scripting Bridge and OmniGraffle
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][/CODE]; 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; }[/CODE] Anyone have any experiences using Scripting Bridge and OmniGraffle? Thanks! --Eric |
Found Solution.
The shape needs to be added to the graphics array of the layers array of the canvas:
[CODE]OmniGraffleCanvas *mainCanvas = [canvases objectAtIndex:0]; OmniGraffleLayer *mainLayer = [[mainCanvas layers] objectAtIndex:0]; OmniGraffleShape *shape = [[[[omnigraffle classForScriptingClass:@"shape"] alloc] initWithProperties:props] autorelease]; [[mainLayer graphics] addObject:shape]; [/CODE] |
All times are GMT -8. The time now is 03:42 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.