Put the read into try-catch. If it throws an error the key isn't exists yet. If you set it, then write, close, reopen the .psd, the value will be there.
Yeah, I forgot to say that this is exactly what I'm doing right now, but it still feels like a bug?
Hehe, not just this seems like a bug in ToolVM DOM We have to hack our way through. I often feel myself in an abandoned sanitarium.
By the way: the generator's backdoor/brain surgery approach is seems like much more useable in many cases than pure .jsx.
Well, not sure about what Tool DOM is, but if you mean this only happens in ELTK, I get the same error (well, I assume as I only get "ExtendScript error") inside my HTML panel.
What is that generator/backdoor you mention?
The backdoor is generator-core which can run from standalone nodejs or from node enabled panel. It can send .jsx snipplets via socket to PS and get back values from it with the help of Kevlar interface. It can retrieve the full document structure around 150 ms and has methods to store/retrieve custom, json data in the .psd.
Check out the
Generator.prototype.getLayerSettingsForPlugin = function (documentId, layerId, pluginId)
Generator.prototype.setLayerSettingsForPlugin = function (settings, layerId, pluginId)
Ah, that's very interesting, thank you! And that's what I'm actually doing, storing some custom JSON on the xmpMetadata object (I know it's supposed to be XML, but Photoshop doesn't seem to care, and it's easier for me to create, plus only my external tools are going to interpret this data from the PSD itself)
I'll take a look, thanks again!
P.D. This whole ecosystem seems in a broken/undocumented/abandoned state, I really concur with your sanitarium statement of before...