Copy link to clipboard
Copied
I'm trying to make such an extension: it has two buttons. One to "bookmark" a layer, the other to set the bookmarked layer as active layer. This way the user can quickly navigate through the layers without scrolling all the way.
I made a script that appends suffix '^' to the layer's name as a bookmark. It kinda worked, but the problem was, it's very very slow to iterate through all the layers and find the layer with said suffix. If I can store the reference to a layer, it would be instant, but as far as I know, Photoshop script is "stateless" and there is no way to pass a reference from a script to another.
Is there a way to "store" a reference in extension?
I have not worked with extensions, but as far as I know it is possible to pass variables between the script and the extension.
Each layer has its own unique ID (within the document). It is enough to save it to variable and pass to extension. To find how to select a layer, knowing its ID, enter in the search bar 'select layer by id'
If you can't find how to pass the variable, then just save and read it by the script (you can save it to a file, to the document itself as metadata, to an environment
...Store the Layer ID of the layer you marked with the ^. The problem I see is you most likely would want to be able to set more than one bookmark and also be able to remove bookmarks. If you are creating an extension set in the bookmark Buttons Part of the Bookmark layer Layer's name and layer Id Where unset bookmarks will have an empty name and layer ID. Perhaps use a Alt+Click on a Set Bookmarked button remove the bookmark. To Mark a Bookmarked Layer it may be easier to change the layer's co
...Copy link to clipboard
Copied
I have not worked with extensions, but as far as I know it is possible to pass variables between the script and the extension.
Each layer has its own unique ID (within the document). It is enough to save it to variable and pass to extension. To find how to select a layer, knowing its ID, enter in the search bar 'select layer by id'
If you can't find how to pass the variable, then just save and read it by the script (you can save it to a file, to the document itself as metadata, to an environment variable, to photoshop settings file etc.)
Copy link to clipboard
Copied
Store the Layer ID of the layer you marked with the ^. The problem I see is you most likely would want to be able to set more than one bookmark and also be able to remove bookmarks. If you are creating an extension set in the bookmark Buttons Part of the Bookmark layer Layer's name and layer Id Where unset bookmarks will have an empty name and layer ID. Perhaps use a Alt+Click on a Set Bookmarked button remove the bookmark. To Mark a Bookmarked Layer it may be easier to change the layer's color code in the layers Palette rather then parsing the layer mane and adding the ^ suffix. Have Blue be a bookmarked layer color code. You most likely need to store bookmarks information for each open document so the user can switch between documents. If you use the documents Meta Data to store Bookmarks. Bookmarks can persist between edit sessions.
Copy link to clipboard
Copied
Thanks for your reply! My problem isn't how to make the bookmark persistent, however. My problem is that it's very slow to jump to the bookmarked layer. I have the following code to get all the layers:
Copy link to clipboard
Copied
Ok I found it!
Copy link to clipboard
Copied
As part of my personal learning, I collected different methods here:
Copy link to clipboard
Copied
A similar topic cross-referenced as a standard script rather than as an extension, just in case it helps somebody who stumbles over this topic in the future: