Skip to main content
Participant
October 2, 2008
Question

Persistent and unique layer handles

  • October 2, 2008
  • 1 reply
  • 562 views
Hello,
I'm developing a plugin that needs to keep persistent and unique handles to layers across file open/closes. It appears that the SDK only has provisions for accessing layers by name or index and has no way of retrieving a unique persistent handle to a layer from AILayerHandle. I'd like to save a set of selected layers to disk (XMP, resource fork, etc) and retrieve this information the next time the file is opened. I can do this now using layer names, but since they are not required to be unique, it causes problems if there are duplicates. Any help is appreciated, thanks.

--josh
This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
October 3, 2008
The best way I can think of would be to get an UID from the suites in AIUID.h for a layer's group. Once you have this, it should be persistent. With that in hand, you can retrieve the artwork -- if it exists -- very easily in a line or two of code.

The question then becomes how to store it. I believe there's a string version of the UID you can store, but there's another way that might be more elegant. Every document has a dictionary, and there's an entry type (UIDType) that's perfectly suited for this. Just create your own key (or maybe create an array entry first, and then have a list of said UIDType entries) and store away. Then you just need to get the layer of the art you get back and you should be good to go.