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

count number of objects in a group

Engaged ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

Hi!

I don´t know if it is that obviously but I didn't found an explanation why this line causes an error:

alert(app.documents[0].groups[0].count());

The group contains a rectangle and a textFrame. (I want to separate those groups from others with more objects or other KIND of objects.)

Here I´ve read something like:

...

number count ()

Displays the number of elements in the Group.

...

Did I misunderstood the hint?

regards

A.

TOPICS
Scripting

Views

1.9K

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

Community Expert , May 03, 2017 May 03, 2017

alert(app.documents[0].groups[0].allPageItems.length)

Votes

Translate

Translate
Participant ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

Hi; try this

alert(app.documents[0].groups[0].rectangles.count());

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 ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

Hi & thanks!

herewith I just get the number of rectangles. But I need the number of all the objects inside.

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
Community Expert ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

alert(app.documents[0].groups[0].allPageItems.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 ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

Thank you peter for the (again) perfect shot from the hip.   

Sometimes I mess with such trifles for two days ...

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
Participant ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

Yes;
Notice the difference between the two

alert(app.documents[0].groups[0].allPageItems.length); 

1.jpg

alert(app.documents[0].groups[0].pageItems.length); 

2.jpg

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 ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

I suppose the fourth item is the group itself (?)

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
Participant ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

No! image and container(Frame)

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 ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

I try to understand...

initial situation: you have a group of a rectangel, a textFrame and a picture. Is that right?

And with "allPageImages" you can recall even "nested" objects.

That´s a good hint. thanks

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
Community Expert ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

And with "allPageImages" you can recall even "nested" objects.

FWIW: One exception:
Not active states of a MultiStateObject (MSO) are left out.

Regards,
Uwe

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
Community Expert ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

Hm. Seems that you removed the last reply.

FWIW: I just wanted to answer:

You first have to resolve the pageItem with getElements() ( returns an Array ).

( If you ask for pageItem you'll get pageItem ( in most cases ) 😉 )

var resolvedItem = app.documents[0].groups[0].pageItems[0].getElements()[0];

if(resolvedItem.constructor.name == "Rectangle")

{// do something};

Regards,

Uwe

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 ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

LATEST

Yes. sorry.

I found the solution and didn´t want to bother the community with boring questions...

But thanx you for your answer with helpful facts.

Regards

A.

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