Copy link to clipboard
Copied
Hi there,
I need to scale down Grouped objects on a layer in Indesign. How can I target this in a script.
Layer is called "Layer 1" objects are called "Group 0" to "Group 9".
Any ideas would be greatly appreciated.
Kind regards,
Steve
var doc = app.activeDocument;
var layer = doc.layers.itemByName("Layer 1");
for (var i = 0; i < 10; i++) {
var groupName = "Group " + i;
var group = layer.groups.itemByName(groupName);
if (group.isValid) {
// Scale down the group to 50% of its original size
group.resize(CoordinateSpaces.PASTEBOARD_COORDINATES, AnchorPoint.CENTER_ANCHOR, ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY, [0.5, 0.5]);
}
}
Copy link to clipboard
Copied
Do you have any scripting knowledge - and looking for guidance - or are you looking for a ready-made script?
Do you have any TextFrames in those groups? Do you want to preserve PointSize or you are OK with it being "wrong" after scaling?
Is it one page or multiple pages?
Do you have any other objects on this layer?
Copy link to clipboard
Copied
If there are ONLY groups with those names - and you want to scale all of them in the whole document - this should work:
app.activeDocument.layers("qqq").groups.everyItem().horizontalScale = 0.5;
app.activeDocument.layers("qqq").groups.everyItem().verticalScale = 0.5;
But if you need more sophisticated solution - I'm pretty sure someone will pitch in.
Copy link to clipboard
Copied
Or if you've even basic JS coding experience - you need to iterate through the collection of groups of the required layer of the activeDocument - check applied label - and set scale.
Copy link to clipboard
Copied
var doc = app.activeDocument;
var layer = doc.layers.itemByName("Layer 1");
for (var i = 0; i < 10; i++) {
var groupName = "Group " + i;
var group = layer.groups.itemByName(groupName);
if (group.isValid) {
// Scale down the group to 50% of its original size
group.resize(CoordinateSpaces.PASTEBOARD_COORDINATES, AnchorPoint.CENTER_ANCHOR, ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY, [0.5, 0.5]);
}
}
Copy link to clipboard
Copied
This works perfectly, many thanks
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more