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

GROUP all oblects in the whole document

Community Beginner ,
Nov 23, 2020 Nov 23, 2020

Copy link to clipboard

Copied

Hi all, 

I need help for a script to group all the items (tiff, textframe, ai, pdf...) of every single spread of my .indd documents.

I tried to modify this script (that works only in the active page) with no results:

 

var doc = app.documents[0];
var myItems = app.activeWindow.activeSpread.pageItems.everyItem();
myItems.locked = false;
var myGroup = doc.groups.add(myItems);
app.select(myGroup);
 
Some help? 
Thanks in advance.
TOPICS
Scripting

Views

245

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 , Nov 23, 2020 Nov 23, 2020

I read from that you would prefer not to group items on the pasteboard.

So here we go:

 

var doc = app.documents[0];
var spreadsArray = doc.spreads.everyItem().getElements();

// Unlock all layers and items on all document spreads.
// All masters will be not changed.

doc.layers.everyItem().locked = false ;
doc.spreads.everyItem().pageItems.everyItem().locked = false ;


// Now loop the spreads:
for( var n=0; n<spreadsArray.length; n++ )
{
	var allItemsOfCurrentSpreadPagesArray = 
	spreadsArray[
...

Votes

Translate

Translate
Community Expert ,
Nov 23, 2020 Nov 23, 2020

Copy link to clipboard

Copied

Hi,

should be items on the pasteboards be also part of a group?

 

Regards,
Uwe Laubender

( ACP )

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 Beginner ,
Nov 23, 2020 Nov 23, 2020

Copy link to clipboard

Copied

Hi,

thanks for the answer.

It's the same. I usually don't leave element in the pasteboard. (thanks to my O.C.D. 😄 )

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 ,
Nov 23, 2020 Nov 23, 2020

Copy link to clipboard

Copied

I read from that you would prefer not to group items on the pasteboard.

So here we go:

 

var doc = app.documents[0];
var spreadsArray = doc.spreads.everyItem().getElements();

// Unlock all layers and items on all document spreads.
// All masters will be not changed.

doc.layers.everyItem().locked = false ;
doc.spreads.everyItem().pageItems.everyItem().locked = false ;


// Now loop the spreads:
for( var n=0; n<spreadsArray.length; n++ )
{
	var allItemsOfCurrentSpreadPagesArray = 
	spreadsArray[n].pages.everyItem().pageItems.everyItem().getElements();
	
	// Do nothing if there is no or only one element on a spread:
	if( allItemsOfCurrentSpreadPagesArray.length < 2 ){ continue };
	
	// Finally add a group with all items on the spread.
	// NOTE: No items on the pasteboard will be grouped.
	spreadsArray[n].groups.add( allItemsOfCurrentSpreadPagesArray );
};

 

 

Regards,
Uwe Laubender

( ACP )

 

// EDITED one comment in the script code:

All > "No items on the pasteboard will be grouped."

The first version unedited also grouped items on the pasteboard, but I changed that to items on pages only.

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 Beginner ,
Nov 23, 2020 Nov 23, 2020

Copy link to clipboard

Copied

LATEST

IT WORKS PERFECTLY!

Thank you very much!!!!! 

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