Copy link to clipboard
Copied
I'm having long term bugs with having one layer in the Document:
ReadLayerDesc *readLayerDesc = gFilterRecord->documentInfo->layersDescriptor;
But this only happens when there's one image (Assuming the layer array is not initialized when there's only one layer present), even looking through the (FilterRecordPtr)`filterRecord` the only accessable data is the `documentInfo` property...
What's the solution to this to acquire a single layer from the descriptor with the filterRecord?
Copy link to clipboard
Copied
Currently the only work around to this is for me to create a layer and just break out of my iteration of the `layersDescriptor` when it hit's the created layer.
I'm not a fan of hacks.
Copy link to clipboard
Copied
You probably have a background only document. Photoshop treats this kind of document special. In this case look at the targetCompositeChannels. We call it a simple document internally and as you have seen it reports NO layers. If you double click the "Background" text in the layers panel and give the layer a name you have now created a document with one layer. But that means no layers as you have one layer. So you need a document with more than one to get "layers" to have something besides NULL. Check out the PoorMans example and how it deals with this situation.
Recap:
Test with a "Background" only.
Test with a layer.
Test with a "Background and a layer.
Test with multiple layers.
Copy link to clipboard
Copied
Thanks for the reply Tom, just to confirm.
The PS document changes when there's only one layer in the scene? (I understand there's not a list / "Layers" of them, it's just a little bit backwards from a technical OOP standpoint to switch a vector / list out for a object when they both contain the same properties in the end)
None of the artists use background layers, and if one is found I remove it in the automation process, since the background layer contain different properties than a layer.
Copy link to clipboard
Copied
Background layers are a terrible problem in using Actions to Scripts development. Often the ExtendScript coder has no idea what kind of file the Action used to build it. But Actions seem to work with or without the BGlayer. We now know how to build the Actions without using the Layers panel but old ones are hit and miss.
For Plugins, we flatten then un-flatten the input before continuing.
RONC
Copy link to clipboard
Copied
Yeah I've learned how background layers contain completely different properties than a document layer, so we don't ever use them.