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

How do I obtain the geometricBounds of a group object?

Guide ,
Oct 09, 2025 Oct 09, 2025

I want to make the image on the right the same size as the entire grouped object on the left.
But I don't know how to get its geometric boundaries.
How do I determine that it's part of the group?

666.png

TOPICS
How to , Scripting
162
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

Community Expert , Oct 09, 2025 Oct 09, 2025

How do I determine that it's part of the group?

 

If you can assume the selection has only 2 objects (?), a group and a recatangle:

 

var s = app.activeDocument.selection
var ob, gb;
for (var i = 0; i < s.length; i++){
    if (s[i].constructor.name != "Group") {
        //the group’s bounds
        ob = s[i].geometricBounds
    } else {
        //the page item outside of the group
        gb = s[i].geometricBounds
    }
};   
$.writeln("Group’s bounds: " + gb + "\rObjects’s bounds: " + ob)
//yo
...
Translate
Community Expert ,
Oct 09, 2025 Oct 09, 2025

Using the Control Panel you can find out the outer dimensions (the W and H fields) of the selected group (first picture). Then select the second image and find its dimensions (second picture). You can then set up a proportions to determine the enlargement needed to match the dimension of the height of the original set of objects. In setting up the proportion of 54.807 (first picture) divided by 35.245 (second picture) I got the enlargement percentage of 155.5 percent and then entered that value into the fields of the scale tool. As seen in the third picture the height of the picture now matches the grouped set. The enlarged second photo is  slightly wider than the group but that can either be adjusted or ignored as needed.

PROPORTIONS.png

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
Community Expert ,
Oct 09, 2025 Oct 09, 2025

This user is looking for scripting solutions. They also are for notorious for not showing what scripting solutions they have tried. The Group object does have a geometricBounds property.

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
Community Expert ,
Oct 09, 2025 Oct 09, 2025

How do I determine that it's part of the group?

 

If you can assume the selection has only 2 objects (?), a group and a recatangle:

 

var s = app.activeDocument.selection
var ob, gb;
for (var i = 0; i < s.length; i++){
    if (s[i].constructor.name != "Group") {
        //the group’s bounds
        ob = s[i].geometricBounds
    } else {
        //the page item outside of the group
        gb = s[i].geometricBounds
    }
};   
$.writeln("Group’s bounds: " + gb + "\rObjects’s bounds: " + ob)
//your sample returns
//Group’s bounds: 50.5000000000001,20,105.306988143723,99.4833333333335
//Objects’s bounds: 64.7548342169696,120,100,172.867748674545
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
Guide ,
Oct 09, 2025 Oct 09, 2025

Hi rob day.

Thank you very much.

Perhaps this is all I need.

if (s[i].constructor.name != "Group") 


I may have misunderstood some things.

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
Community Expert ,
Oct 10, 2025 Oct 10, 2025
LATEST

I may have misunderstood some things.

 

You will need to get the group’s geometric bounds in order to set the rectangle’s bounds and position it relative to the group.

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