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

113

Likes

translate

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

Adobe Community Professional , 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[...

Likes

translate

Translate

Translate
Adobe Community Professional ,
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 )

Likes

translate

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. 😄 )

Likes

translate

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
Adobe Community Professional ,
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.

Likes

translate

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

IT WORKS PERFECTLY!

Thank you very much!!!!! 

Likes

translate

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