• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Photoshop CS6 - eventSave callback

New Here ,
Aug 20, 2013 Aug 20, 2013

Copy link to clipboard

Copied

Hi everybody,

I'm trying to develop my first plugin and I'm experiencing a problem.

I'd like to export a file in a very specific format whenever I save a PSD file, without having to save it in a different step.

The purpose of this file is to be fed to another piece of software, but I don't want the user to deal with it, it should be transparent as far as he's concerned.

I don't need to read it back in Photoshop, it's not a new file format.

I figured that the best way to do so would be to create an Export plugin.

To make it work I also created a second plugin in charge of registering the necessary callback, basically the eventSave callback.

In my OnFileSaved callback method I call the export through a sPSActionControl->Play call.

This workflow works very well when I save a PSD file through a "File/Save" or "File/Save As" call.

Unfortunately it doesn't work when I close an unsaved file and answer yes to the "would you like to save the file first" popup window.

The OnFileSaved function is invoked but the sPSActionControl->Play call fails with a message stating that the Export function is unavailable.

My understanding is that the file is probably already closed when the function is invoked and that Photoshop prevents me from doing anything because the resource is no longer available.

My question for you is twofold:

- do you know a better way to do what I want to do?

- is there a way to register a before close callback, that would give me an opportunity to export my special file?

By the way, I've tried registering the eventAll callback, hoping to find one that would be fired before the eventClose one without any success.

Thank you in advance for your help:-)

Sebastien

TOPICS
SDK

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Aug 20, 2013 Aug 20, 2013

1. Yeah, I think it would be reasonable to get a save event in this case however you won't get any. What you get instead is a close one, with a path. Look for keySaving in the close event; if its set to enumYes (which implies the document was saved on close), get the path by keyIn.

Note that the path may be either a full path to the file or just a folder, if the the file was saved under the same name.

2. Unfortuantely, there are no 'before' events in Photoshop - you only are informed about what ha

...

Votes

Translate

Translate
Adobe
Contributor ,
Aug 20, 2013 Aug 20, 2013

Copy link to clipboard

Copied

1. Yeah, I think it would be reasonable to get a save event in this case however you won't get any. What you get instead is a close one, with a path. Look for keySaving in the close event; if its set to enumYes (which implies the document was saved on close), get the path by keyIn.

Note that the path may be either a full path to the file or just a folder, if the the file was saved under the same name.

2. Unfortuantely, there are no 'before' events in Photoshop - you only are informed about what has already happened, so I'm afraid while 1) would allow you to be notified about the fact file was indeed saved, you won't be able to play export at this point.

There are different solutions I can think about for this situation, but none of them are perfect. For example, you can inform the user then automatically re-open the file, re-export it and close, but this is a bit clunky and it won't work if the user is closing Photoshop which is, of course, problematic (in fact, due to an ancient bug which I believe still exists in CC, you cannot reliably show third-party GUI on PS shutdown). On the other hand, if your special format is in fact just a (relatively) lightweight metadata, you can cache it in memory while the document is still alive and then you will be able to save it even when the document is closed .

None of this is ideal, but at least I am unaware about a better way to deal with saved-on-close documents.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 21, 2013 Aug 21, 2013

Copy link to clipboard

Copied

LATEST

Thank You very much for your quick answer Ilya:-)

That's pretty much what I thought unfortunately:-(

I can try to maintain a cache as You suggested, it should be fairly easy to do.

I'm going to try it.

Thank you once again for your help, it's much appreciated:-)

Sebastien

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines