Copy link to clipboard
Copied
I have a small problem
I need to know if a group is open or closed
I put up a small script in uxp
but it tells me that the group is always open even if it is closed,
this is the script.
checkLayerGroupStatus()
async function checkLayerGroupStatus() {
const layers = app.activeDocument.layers;
const groupName = "Color";
const layerGroup = layers.find(layer => layer.name === groupName && layer.layers);
if (!layerGroup) {
showAlert( `Level group "${groupName}" not found`);
return;
}
const isOpen = layerGroup.visible;
if (isOpen) {
showAlert(`The level group "${groupName}" is open.`);
} else {
showAlert( `Level group "${groupName}" is closed.`);
}
}
Found also an ExtendScript version.
Verified that it works with this UXP script.
Copy link to clipboard
Copied
Is »visible« not the Layer Visibility which is unrelated to whether a Group is open or not?
Copy link to clipboard
Copied
even if I remove visible the problem remains.
Copy link to clipboard
Copied
Not what I meant.
»visible« seems to refer to the Layer’s/Group’s visibility, so where is the property that describes whether a Group is expanded?
Copy link to clipboard
Copied
@DBarranca , please forgive the intrusion.
Do you know whether in UXP Scripting Groups have a property that indicates whether they are closed or expanded in the Layers Panel?
Copy link to clipboard
Copied
I haven't found anything about it, I hope Barranca passes by this post.
Copy link to clipboard
Copied
c.pfaffenbichler How could the same thing be with javascript. I'll see if I can adapt it.
Copy link to clipboard
Copied
c.pfaffenbichler How could the same thing be with javascript. I'll see if I can adapt it.
As far as I can tell ESTK Scripting does not provide a property for determining that.
There have been work-arounds to open and close a Group but those were less than elegant.
Copy link to clipboard
Copied
It seems that layerSectionExpanded is the property being sought. Get it via batchPlay.
Copy link to clipboard
Copied
Found also an ExtendScript version.
Copy link to clipboard
Copied
Dang, fully missed that one!
Copy link to clipboard
Copied
Thank you for your help but I couldn't solve it.
Copy link to clipboard
Copied
What is the reason for that?
Copy link to clipboard
Copied
Dang again!
As the property worked fine in ESTK Scripting I assumed the UXP samples @sttk3 linked to would work out for you.
Copy link to clipboard
Copied
Verified that it works with this UXP script.
Copy link to clipboard
Copied
@sttk3
wonderful
I wasted two days trying to figure out how to fix the problem
but I couldn't
thank you so much for your help
Copy link to clipboard
Copied
In other words, the problem was solved by my code, correct?
Copy link to clipboard
Copied
Yes your code is perfect. Thank you with all my heart.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now