Skip to main content
Known Participant
June 26, 2022
Answered

Editing multiple objects

  • June 26, 2022
  • 3 replies
  • 867 views

Hello Experts

 

I am looking for a way to edit multiple objects at the same time.

 

These are cases where the Global Edit and the Select menu is not able to find all the objects I want to edit.

 

At some point I recall that maybe there was a shortcut ket sequence that would work. Alt+Shift+?+?.

 

For example, I want to change the size of multiple objects that are of different sizes to the same size. But when I select them individually and go to Properties to edit their size the H & W show the H & W of the group, not individuals objects.  In this case, how do I edit the size of individuals objects?

 

Thanks!

This topic has been closed for replies.
Correct answer Disposition_Dev

if you have multiple objects and you want to resize each of them variably, you'll need a script. As you pointed out, transform each uses a uniform scale percentage, so you'd have to select all of the items that should be scaled by a certain percentage, then scale them, deselect and then select the next group.

 

Fortunately a script for this purpose is really straightforward. Obtain an array of the items you want to process (this could be by pre-selecting them in the UI before running the script, targeting a certain layer, or programatically identifying the necessary elements. for the purposes of this example, I'll assume you already have an array of items.. Then if need be, we can discuss how to obtain that array. Try this snippet:

 

function resizeObjectsToSpecificSize()

{

    var doc = app.activeDocument;

    var layers = doc.layers;

    var itemsToResize = [];

    //populate the array of items to resize.. for this example, i'm just targeting everything on layers[0];

    for(var i=0;i<layers[0].pageItems.length;i++)

    {

        itemsToResize.push(layers[0].pageItems[i]);

    }

    const DW = 50; //desired width: 50pt

    const DH = 50; //desired height: 50pt

    for(var i=0;i<itemsToResize.length;i++)

    {

        itemsToResize[i].width = DW;

        itemsToResize[i].height = DH;

    }

}

 

 

resizeObjectsToSpecificSize(app.activeDocument.layers[0]

 

 

Edit* the above will set the absolute height/width to whatever values are in those constants. To scale proportionally, you'll need to identify the largest dimension of the current object, then do the math to get a scale percentage which will scale the object such that the largest dimension matches your desired dimension. like this:

 

var myItem = doc.layers[0].pageItems[0];

var largestDimension = myItem.width > myItem.height ? myItem.width : myItem.height;

const desiredDimension = 50; //50pt desired dimension of largest side of object

var scaleFactor = (desiredDimension/largestDimension)*100; // (target value divided by current value) quantity to get a ratio, multiplied by 100 to make a percentage

myItem.resize(scale,scale);

3 replies

Disposition_Dev
Disposition_DevCorrect answer
Legend
August 24, 2022

if you have multiple objects and you want to resize each of them variably, you'll need a script. As you pointed out, transform each uses a uniform scale percentage, so you'd have to select all of the items that should be scaled by a certain percentage, then scale them, deselect and then select the next group.

 

Fortunately a script for this purpose is really straightforward. Obtain an array of the items you want to process (this could be by pre-selecting them in the UI before running the script, targeting a certain layer, or programatically identifying the necessary elements. for the purposes of this example, I'll assume you already have an array of items.. Then if need be, we can discuss how to obtain that array. Try this snippet:

 

function resizeObjectsToSpecificSize()

{

    var doc = app.activeDocument;

    var layers = doc.layers;

    var itemsToResize = [];

    //populate the array of items to resize.. for this example, i'm just targeting everything on layers[0];

    for(var i=0;i<layers[0].pageItems.length;i++)

    {

        itemsToResize.push(layers[0].pageItems[i]);

    }

    const DW = 50; //desired width: 50pt

    const DH = 50; //desired height: 50pt

    for(var i=0;i<itemsToResize.length;i++)

    {

        itemsToResize[i].width = DW;

        itemsToResize[i].height = DH;

    }

}

 

 

resizeObjectsToSpecificSize(app.activeDocument.layers[0]

 

 

Edit* the above will set the absolute height/width to whatever values are in those constants. To scale proportionally, you'll need to identify the largest dimension of the current object, then do the math to get a scale percentage which will scale the object such that the largest dimension matches your desired dimension. like this:

 

var myItem = doc.layers[0].pageItems[0];

var largestDimension = myItem.width > myItem.height ? myItem.width : myItem.height;

const desiredDimension = 50; //50pt desired dimension of largest side of object

var scaleFactor = (desiredDimension/largestDimension)*100; // (target value divided by current value) quantity to get a ratio, multiplied by 100 to make a percentage

myItem.resize(scale,scale);

jdballouAuthor
Known Participant
September 5, 2022

Excellent!  I will try that out. 

Many thanks.

jdballouAuthor
Known Participant
September 5, 2022

Yes - I would like to know more about how to add objects to an array. I brought the layer with the objects I wanted to re-size to the top and ran the script, but got an error on line 52 - which I assume is the final Resize line.

Monika Gause
Community Expert
Community Expert
August 24, 2022

There is a script called "Set all the Things"

 

But could you perhaps show a screenshot of the problem?

Mylenium
Legend
June 26, 2022

Transform Each... or more advanced script-based solutions.

 

Mylenium

jdballouAuthor
Known Participant
August 24, 2022

Thanks. But Transform each does not allow me to specify the width or height of the objects, which is what I want to do. It only allows me to scale them by a %.

Any other ideas?