Skip to main content
Inspiring
January 14, 2025
Answered

I need to scale down Grouped objects on a layer. How can I target this in a script.

  • January 14, 2025
  • 4 replies
  • 279 views

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

Correct answer Anantha Prabu G

Hi @Steve25219687xhr4 

 

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]);
    }
}

 

4 replies

Anantha Prabu G
Anantha Prabu GCorrect answer
Legend
January 15, 2025

Hi @Steve25219687xhr4 

 

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]);
    }
}

 

Thanks,PrabuDesign smarter, faster, and bolder with InDesign scripting.
Inspiring
January 15, 2025

This works perfectly, many thanks

Robert at ID-Tasker
Legend
January 14, 2025

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.

 

Robert at ID-Tasker
Legend
January 14, 2025

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.

 

Robert at ID-Tasker
Legend
January 14, 2025

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?