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

javascript: how to access the elements of a group?

Engaged ,
Dec 05, 2021 Dec 05, 2021

Copy link to clipboard

Copied

Hello,

I have the problem to access the elements of a group with javascript.

 

Bildschirmfoto 2021-12-05 um 17.44.12.png

 

var vDocRef = app.activeDocument;
var vSelection = vDocRef.selection;
var vLen = vSelection.length;
for (var i = 0; i < vLen; i++) { // for-03
			vName = vSelection[i].name;
			alert(i + " " + vName + " " + vSelection[i].typename);
				if (vSelection[i].typename == "GroupItem") { 
					// how to access to the group elements?
					alert("gruppe " + vSelection[i].groupItems.length); // is 0, but why?
				}
}

 

 

But the alert shows only/allways zero (0) and I can't access the elements of the group. What can I do?

 

Jens.

TOPICS
Scripting , SDK

Views

203

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

Guide , Dec 05, 2021 Dec 05, 2021
You're getting 0 because vSelection[i] is a groupItem, but doesn't contain groupItems as members of the group.  Change the line to

 

alert("gruppe " + vSelection[i].pageItems.length);

 

Votes

Translate

Translate
Adobe
Guide ,
Dec 05, 2021 Dec 05, 2021

Copy link to clipboard

Copied

You're getting 0 because vSelection[i] is a groupItem, but doesn't contain groupItems as members of the group.  Change the line to

 

alert("gruppe " + vSelection[i].pageItems.length);

 

Votes

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
Engaged ,
Dec 05, 2021 Dec 05, 2021

Copy link to clipboard

Copied

LATEST

Hello and thanks for the tip. That will do it. Now I can write my script to the end. 

Votes

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