Is it possible to add user-defined data to layers, in the same way that you might add a custom attribute to a node in Maya? For example, for me to add a new string property to a layer that I would access with app.activeDocument.layers[0].myProperty
?
I donât know of a way of directly customizing layer data and as far as I know from the Photoshop file spec there are no hooks in the layer data to accommodate custom data. That said there is support for arbitrary metadata on the document level and so you could add per-layer data by storing/accessing it by e.g. layer ID (obviously youâd have to come up with a way of handling layer merging and duplication etc.). There is a lengthy thread about accessing document metadata here: Document XMP metadata
thanks for the reply. Its good to know that there is metadata on the document level which can be edited.
The docs say that IDs are only relevant for the current photoshop sessionâs lifetime, so it might not be possible to save layer-specific data that is valid across multiple sessions (havenât tested this myself yet).
Document ID is temporary. Layer ID is saved within document and persistent.
Document can have XMP metadata and every layer can have its own XMP metadata too. In addition layer can have âgeneratorâ metadata.
If you write code as in your example it will be added only to this one specific layer instance and it might or might not be available once you get that instance again. If next instance will be taken from internal cache then it could stay there within scope of your plugin until the plugin is reloaded. So rather donât do that.
Additionally, you can add your own properties like this: https://developer.adobe.com/photoshop/uxp/2022/ps_reference/media/prototype/
Would you mind pointing me to that section in the docs? In my experience so far (definitely with extendScript and it seems like with UXP as well) they stay persistent and get saved with the document (according to the file spec) under resource âlyidâ. In fact what Iâve been describing to you is something that we do in our pipeline.
@Jarda, the properties added to prototypes arenât saved with the document, are they?
That is correct they are not