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 Today's Posts

 
Dictionary for initializing shape properties when using Objective-C ScriptBridge Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
I'm using Objective-C ScriptBridge to build some shapes in OmniGraffle.
I'm able to create and add the shape to a canvas, but there are many properties which I can't figure out how to set correctly.
For instance I'm able to set things like origin, side padding, size, draws shadow. But I can't figure out how to set text placement. This shows as an enum.
I need to make that an object so that it can be added to the dictionary which I'm using as properties to initialize the shape (initWithProperties)... It looks something like this:
Code:
OmniGraffleShape *anotherGraffleShape = [[[self.graffleApp classForScriptingClass:@"shape"] alloc] initWithProperties:[self grafflePropertiesForHostShape:shapeMetaData]];
Here is a sample of my dictionary which I'm passing for the initWithProperties:

Code:
NSMutableDictionary *graffleProperties = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                          [NSNumber numberWithInt:shapeMetaData.sidePadding],@"sidePadding",
                                          [NSArray arrayWithObjects:[NSNumber numberWithInt:shapeMetaData.startingXOrigin],[NSNumber numberWithInt:shapeMetaData.startingYOrigin], nil],@"origin",
                                          [NSArray arrayWithObjects:[NSNumber numberWithInt:shapeMetaData.shapeWidth],[NSNumber numberWithInt:shapeMetaData.shapeHeight], nil],@"size",
                                          [NSNumber numberWithBool: shapeMetaData.drawsShadow],@"drawsShadow",
                                          [NSNumber numberWithBool: shapeMetaData.drawsStroke],@"drawsStroke",
                                          [NSNumber numberWithDouble:shapeMetaData.cornerRadius],@"cornerRadius",
                                          [NSString stringWithFormat:@"%c", OmniGraffleOGvaTop],@"textPlacement",
                                          nil];
It it wasn't obvious, the above example is using a custom object calls shapeMetaData, which I set most of the properties for a shape. Here I'm just getting those properties and adding them to a dictionary which will later be used to initialize the OmniGraffle Shape object.

I would really appreciate any examples of how to set the various properties for a shape. It would be even better if somebody could show an example of how to build a properties dictionary with most every property in the example.

Last edited by Joe.Hocker; 2013-11-07 at 11:04 PM.. Reason: wrapping some code with code attributes
 
 





All times are GMT -8. The time now is 12:09 AM.


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