Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

check if a group is open or closed

Enthusiast ,
Feb 03, 2025 Feb 03, 2025

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.`);
    }
}
TOPICS
Actions and scripting
982
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Feb 04, 2025 Feb 04, 2025

Found also an ExtendScript version.

Translate
Community Expert , Feb 05, 2025 Feb 05, 2025

Verified that it works with this UXP script.

Translate
Adobe
Community Expert ,
Feb 03, 2025 Feb 03, 2025

Is »visible« not the Layer Visibility which is unrelated to whether a Group is open or not? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 03, 2025 Feb 03, 2025

even if I remove visible the problem remains.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2025 Feb 03, 2025

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2025 Feb 03, 2025

@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? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 03, 2025 Feb 03, 2025

I haven't found anything about it, I hope Barranca passes by this post.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 03, 2025 Feb 03, 2025

c.pfaffenbichler How could the same thing be with javascript. I'll see if I can adapt it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2025 Feb 03, 2025
quote

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2025 Feb 03, 2025

It seems that layerSectionExpanded is the property being sought. Get it via batchPlay.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 04, 2025 Feb 04, 2025

Found also an ExtendScript version.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 04, 2025 Feb 04, 2025

Dang, fully missed that one! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 05, 2025 Feb 05, 2025

Thank you for your help but I couldn't solve it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2025 Feb 05, 2025

What is the reason for that?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2025 Feb 05, 2025

Dang again! 

As the property worked fine in ESTK Scripting I assumed the UXP samples @sttk3 linked to would work out for you. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2025 Feb 05, 2025

Verified that it works with this UXP script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 06, 2025 Feb 06, 2025

@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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2025 Feb 06, 2025

In other words, the problem was solved by my code, correct?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 06, 2025 Feb 06, 2025
LATEST

Yes your code is perfect. Thank you with all my heart.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines