View Single Post
Hi all,

Using the Scripting Bridge in 10.5 and OmniGraffle 5 Pro I'd like to do the following:
I'd like to export the individual parts of a user-selected Illustration within a Document. The Illustration should not be exported as one entity (I got this working already), but as individual images. The reason for this is that I plan to use the individual parts for animation purposes in PowerPoint 2008 / Keynote 08. The Problem now is the following:
The export using the Document works
Code:
self.selectedItems = self.selectedOmniGraffleWindow.selection;
NSString *tempDirectory = [openPanel directory];
NSLog(@"Chosen directory: %@",tempDirectory);
for (int i=0; i< [self.selectedItems count]; i++) 
{
	OmniGraffleGraphic *item = [self.selectedItems objectAtIndex:i];
	NSString *fileName = [NSString stringWithFormat:@"/%d",i];
	NSString *finalDirectory = [tempDirectory                                      
                                                   stringByAppendingString:fileName];
	NSURL *exportDirectory = [NSURL URLWithString:finalDirectory];
	[currentDocument saveAs:@"png" in:exportDirectory]; 
          // This does work - It just exports the whole selection!
}
However, If I replace the call to currentDocument with item, as it was originally intended to iterate over the different graphics in the selection,
Code:
[item saveAs:@"png" in:exportDirectory];
it fails with an exception.

My questions:

1. Is it mandatory to use the OmniGraffleDocument class to export items?

The AppleScripts regarding export I've seen so far seem to indicate that.
However, in the generated header file used by the Scripting Bridge (generated using the sdef command in Terminal), both OmniGraffleDocument and OmniGraffleGraphic inherit from OmniGraffleItem, which supplies the saveAs: in: method.

2. If it is mandatory to use OmniGraffleDocument, is it somehow possible to modify the selection of the Document?
With that, I also would get the desired effect of iterating over the Array of selections and exporting the items one by one.

I appreciate any comments!

Thx in advance!

Toby