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

Unlocking sublayers

Explorer ,
May 27, 2016 May 27, 2016

I am trying to resize some art to specific dimensions. The script ran fine except for 1 file and it drove me crazy trying to find why 1 layer would not resize. I checked to make sure the layer wasn't locked:

layer3.png

and it looked fine. I used the line currentLayer.locked=false; to unlock any locked ones. Finally, I checked the sublevels and, sure enough, there was a level locked.

layer4.png

Is there a way to unlock all sublayers?

TOPICS
Scripting
1.5K
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 1 Correct answer

Participant , May 28, 2016 May 28, 2016

function unlock ( items ) {

    var i = items.length;

    if ( i ) {

        while ( i-- ) {

            items.locked = false;

            if ( items.typename === 'GroupItem' ) {

                unlock( items.pageItems );

            }

                else if ( items.typename === 'Layer' ) {

                    unlock( items.layers );

                    unlock( items.pageItems );

                }

        }

    }

}

unlock( activeDocument.layers );

Translate
Adobe
Participant ,
May 27, 2016 May 27, 2016

As an option:

function unlockedSubLayers ( layers ) {

    var i = layers.length;

    if ( i ) {

        while ( i-- ) {

            layers.locked = false;

            unlockedSubLayers( layers.layers );

        }

    }

}

unlockedSubLayers( activeDocument.layers );

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
Explorer ,
May 27, 2016 May 27, 2016

I had tried something very similar and it didn't work.

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
Explorer ,
May 28, 2016 May 28, 2016

You're right. Could explain why my unlock function didn't work. New to javascript. How would I unlock a locked raster item?

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
Valorous Hero ,
May 27, 2016 May 27, 2016

Matter of fact that doesn't look like a locked sub-layer, it looks like a locked raster item!

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
Participant ,
May 28, 2016 May 28, 2016

function unlock ( items ) {

    var i = items.length;

    if ( i ) {

        while ( i-- ) {

            items.locked = false;

            if ( items.typename === 'GroupItem' ) {

                unlock( items.pageItems );

            }

                else if ( items.typename === 'Layer' ) {

                    unlock( items.layers );

                    unlock( items.pageItems );

                }

        }

    }

}

unlock( activeDocument.layers );

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
Explorer ,
May 28, 2016 May 28, 2016
LATEST

Thanks alexander and silly-v.

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