How to validate if particular group contain subgroup and object?

Explorer ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

Daksri_0-1658319898180.png

From the above , i hav eto validate if Group has subgroup and object .Code i have written is -

var doc = app.activeDocument;
var lar = doc.layers[0].groupItems[0];
for(var i=0;i<lar.length;i++)
{
   if( i == 0)
   {
      if(lar.groupItems[0].typename == "GroupItem" && lar.pathItems[0] == true)
      {
         alert("inside if");
      }
      else
      Log.qaError("nbmh");
   }
   else i++;
}
Please guide me, where  i am wrong .
TOPICS
Scripting

Views

61

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 1 Correct answer

Explorer , Jul 20, 2022 Jul 20, 2022

Sure sir !!

Below is the solution to this -

var docRef = app.activeDocument;
var vSelected = docRef.selection;
var vParent = vSelected[0];
var vNumbers = vParent.pageItems.length;
for ( var i = 0; i < vNumbers; i++ ) {
    var vChild = vParent.pageItems[i];
    if(vChild.typename == "GroupItem")
    {
        Log.qaComment("Pass : Group is created");
    }
    else if(vChild.typename == "PathItem")
    {
        Log.qaComment("Pass: Group with one object is created");
    }
    else
    Log.qaError("Fail : Gr
...

Likes

Translate

Translate
Explorer ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

I have found solution to this. Thanks in advance !!

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
Community Expert ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

Why don't you post the solution for others to see?

 

David Creamer: Community Expert, Adobe Certified Instructor, and Adobe Certified Expert (since 1995)

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

Copy link to clipboard

Copied

LATEST

Sure sir !!

Below is the solution to this -

var docRef = app.activeDocument;
var vSelected = docRef.selection;
var vParent = vSelected[0];
var vNumbers = vParent.pageItems.length;
for ( var i = 0; i < vNumbers; i++ ) {
    var vChild = vParent.pageItems[i];
    if(vChild.typename == "GroupItem")
    {
        Log.qaComment("Pass : Group is created");
    }
    else if(vChild.typename == "PathItem")
    {
        Log.qaComment("Pass: Group with one object is created");
    }
    else
    Log.qaError("Fail : Group is not created");
}

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