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

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

Participant ,
Jan 14, 2025 Jan 14, 2025

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

TOPICS
Scripting
307
Translate
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

Engaged , Jan 14, 2025 Jan 14, 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]);
    }
}

 

Translate
LEGEND ,
Jan 14, 2025 Jan 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? 

 

Translate
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
LEGEND ,
Jan 14, 2025 Jan 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.

 

Translate
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
LEGEND ,
Jan 14, 2025 Jan 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.

 

Translate
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 ,
Jan 14, 2025 Jan 14, 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,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
Translate
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 ,
Jan 15, 2025 Jan 15, 2025
LATEST

This works perfectly, many thanks

Translate
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