The Omni Group Forums

The Omni Group Forums (
-   OmniGraffle General (
-   -   Export issue / Modify the selection in a Document via AppleScript / Scripting Bridge (

Scifer_2008 2008-10-08 07:06 AM

Export issue / Modify the selection in a Document via AppleScript / Scripting Bridge
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
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
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]; [/CODE]
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!


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

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