The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniGraffle General (http://forums.omnigroup.com/forumdisplay.php?f=10)
-   -   Export issue / Modify the selection in a Document via AppleScript / Scripting Bridge (http://forums.omnigroup.com/showthread.php?t=10138)

Scifer_2008 2008-10-08 06: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
[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!
}
[/CODE]

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!

Toby


All times are GMT -8. The time now is 10:34 PM.

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