How to select sublayer ? [how to select objects by name?]

Explorer ,
Jul 06, 2022 Jul 06, 2022

Copy link to clipboard

Copied

Swai1_0-1657103226796.png

I have to select rectangle . code i have written is this - 

var lar = app.activeDocument.layers[0].layers[2];
if(lar.name == "rectangle")
 

 

TOPICS
Scripting

Views

93

Likes

Translate

Translate

Report

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

Advocate , Jul 06, 2022 Jul 06, 2022

cela peut-il aider,

 

var doc = app.activeDocument;

        if(doc.layers[0].name == "Isolation Mode") alert("mode isolation")
        doc.layers[0].pathItems[0].selected = true;

 

Likes

Translate

Translate
Advisor , Jul 06, 2022 Jul 06, 2022

As implied by @renél80416020 , to test if a pathItem is in isolation mode, test if its parent/layer is named "Isolation Mode". 

alert(app.activeDocument.pathItems.getByName('rectangle').parent.name);

Likes

Translate

Translate
Advisor ,
Jul 06, 2022 Jul 06, 2022

Copy link to clipboard

Copied

That is a pathItem, not a sublayer, so

var item = app.activeDocument.layers[0].pathItems[2];

Likes

Translate

Translate

Report

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 ,
Jul 06, 2022 Jul 06, 2022

Copy link to clipboard

Copied

Yes this is working .But my main  moto is to select rectangle and validate whether it is in Isolation mode or not . Isolation i am doing through AAT. Now this validation part i have to do . I am new  to scripting . Kindly guide me.

var item = app.activeDocument.layers[0].pathItems[2];
if(item.name == "rectangle")
{
if(item.isIsolated == true)
        {
            Log.qaComment("in isolation through layer panel");
        }
else
        Log.qaError("Not in Ioslation mode through layer panel");
}

Likes

Translate

Translate

Report

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
Advocate ,
Jul 06, 2022 Jul 06, 2022

Copy link to clipboard

Copied

cela peut-il aider,

 

var doc = app.activeDocument;

        if(doc.layers[0].name == "Isolation Mode") alert("mode isolation")
        doc.layers[0].pathItems[0].selected = true;

 

Likes

Translate

Translate

Report

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 ,
Jul 07, 2022 Jul 07, 2022

Copy link to clipboard

Copied

LATEST

Thanks for the quick reply. My one more doubt is that - Instead of object , i.e rectangle, now if i am grouping and then i am in Isolation Mode - how that will work ?

var doc = app.activeDocument;

        if(doc.layers[0].name == "Isolation Mode") alert("ok")
        {
        if(doc.layers[0].groupItems[0].isIsolated == true)
        {
alert("in isolation");
}
Daksri_0-1657177864937.png

 

Likes

Translate

Translate

Report

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
Advisor ,
Jul 06, 2022 Jul 06, 2022

Copy link to clipboard

Copied

As implied by @renél80416020 , to test if a pathItem is in isolation mode, test if its parent/layer is named "Isolation Mode". 

alert(app.activeDocument.pathItems.getByName('rectangle').parent.name);

Likes

Translate

Translate

Report

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
Advocate ,
Jul 06, 2022 Jul 06, 2022

Copy link to clipboard

Copied

Salut,

var doc = app.activeDocument;
var rectangle = getPath(doc,"rectangle");
    if (rectangle != undefined) rectangle.selected = true;
function getPath(relativeObjet, nomPath)
{
     try {
     var obj = relativeObjet.pathItems.getByName(nomPath);
     }   catch (e) {
        alert("Le tracé "+nomPath+" spécifié n'existe pas ?");
        return undefined;
        }
     return obj;
}

Il n'y a pas de sous couche ??

Likes

Translate

Translate

Report

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