Copy link to clipboard
Copied
Hi,
I want to resize 4 drawn rectangles of different random widths so that they all have the same width, but it has to fit in the space of their current position, ie when you select them all. I also want them distributed equally in the same space.
Can I do this in Indesign?
Just for fun!
You have this:
… and you want that [4 mm space after resizing]:
… So Play Rock'n Roll! ["undo" in option!]
...app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Resize and Distribute! …");
function main()
{
var myDoc = app.activeDocument;
var mySel = app.selection;
if (mySel.length == 0) exit();
else {
var myGroup = myDoc.groups.add(mySel);
var myGB = myGroup.geometricBounds;
myGroup.ungroup
Copy link to clipboard
Copied
Yes! "Alignment" Panel.
(^/)
Copy link to clipboard
Copied
You would need to do it in two steps. You have three requirements: Same width, the group keeps current width, and equal spacing.
You can't change the width with the Align panel. What width do you want them to be, that's ambiguous right now?
(1) Pick the width you want, select each one and set the W (width) value on the Control panel, keeping the one on the left and right at their current position.
(2) Now select all four rectangles. Using the Align panel (Window > Output & Layout > Align), select Align to Selection:
Then click Distribute Horizontal Centers:
Result:
NOTE: Illustration doesn't show equal width. I added that after I re-read your posting.
Copy link to clipboard
Copied
Oups!
(^/)
Copy link to clipboard
Copied
Thanks for your reply. It's not that simple.
I don't want to pick my width or type in any value, I just want Indesign to come up with the width and space between automatically. I have, say, the width of 180mm for all 4 rectangles, and want all these different sized rectangles to have the same width and space between within 180mm.
My widths are 48, 34, 40 and 30mm, respectively.
Thanks
Copy link to clipboard
Copied
I want 4 mm to be the space between. I forgot to mention that.
Copy link to clipboard
Copied
What width?
(^/)
Copy link to clipboard
Copied
180mm total width, 4mm space between. Can Indesign work out what width they all have to be?
Copy link to clipboard
Copied
siwybiwy wrote:
t's not that simple.
I don't want to pick my width or type in any value, I just want Indesign to come up with the width... and space between automatically. I have, say, the width of 180mm for all 4 rectangles, and want all these different sized rectangles to have the same width and space between within 180mm.
My widths are 48, 34, 40 and 30mm, respectively.
I don't get it. Developers can't install features based on scenarios and rules you have yet make up on the fly.
InDesign has all the tools required to produce the result you need, using perhaps a dozen or more possible tool/method combinations, but like all software, it does require your input.
Based on your 180 mm total with with 4 mm spacing, the simplest math puts your rectangle width at 56 mm. Just draw one of that width, copy it 3 times, select them all, re-click one to make it the key object, then use the Align panel to align their tops or bottoms if necessary, enter 4mm in the Use Spacing field and click the Distribute Horizontal Space button.
Copy link to clipboard
Copied
I gave a simple example. Things can get more complicated with more objects. We all know how to use simple math with alignment and distribution commands in Indesign. I want a simple command that does it in a second. Select all, make them all the same width with a random gap. After that I can select them all and drag to desired width as a group, where the gap will be maintained the same, as will the same widths of the objects.
Copy link to clipboard
Copied
siwybiwy wrote:
We all know how to use simple math with alignment and distribution commands in Indesign.
Well, I wouldn't assume "we all" do, and your first few posts didn't make it obvious that you did.
I want a simple command that does it in a second. Select all, make them all the same width with a random gap.
I guess we all want what we want. Wait, now it's a random gap? Hmm...the way so many use the word "random" wrongly now, I have to ask; do you mean random spacing, or equal spacing of a value that's chosen at random? Frankly, I'm not sure either one makes any sense with respect to software function or page layout.
After that I can select them all and drag to desired width as a group, where the gap will be maintained the same, as will the same widths of the objects.
So you'll resize the group without the size of the objects or the size of the gaps changing? I don't think any amount of Ctrl+drag will ever accomplish that. Ah, I suppose you mean the size of the objects will increase or decrease, but remain equal to each other. I had to reread.
Funny, as much as you would see this as a useful feature, it's a prime example of the type of automatic feature-trick I personally wouldn't want. I prefer that software responds only to my discreet and explicit input, one concept at a time. It helps keep things from happening "accidentally." When you do want multiple concepts executed concurrently or in sequence, scripting comes into play, as this thread and Obi-wan's solution demonstrate perfectly.
Copy link to clipboard
Copied
Nobody needs to explain that he or she CAN use simple math in Indesign, surely.
Random gap means any gap that is consistent/same between the objects.
Let me explain. You take the group (of x width), made even with Obi-wan script, to your chosen group width (y) by dragging the handle of the group selection, and applying the script again to get the old gap back.
I'm sorry you don't find it useful, but I am also sure you'll keep it safely in your script folder .
Copy link to clipboard
Copied
siwybiwy wrote:
Nobody needs to explain that he or she CAN use simple math in Indesign, surely.
Hah. You're right; either way, it often doesn't need to be explained.
Random gap means any gap that is consistent/same between the objects.
I know this is strictly arguing the semantics of it, but it's one of the reasons you got the mistaken impression I had trouble understanding exactly what you wanted. A value (the gap) that is mathematically determined by other non-random factors, as in this case, is not random. For some reason the word has wrongly come to mean "not predetermined;" but random actually means not determined at all, or more accurately, determined by the laws of accident.
Let me explain.
No need. I understood exactly what you wanted, with respect to functionality, since the beginning of the thread. Any misunderstanding on my part was borne of asking "why?" and "how?" more so than "what?" Or perhaps is was in my misinterpretation of your original question; "Can I do this in InDesign?" In retrospect I'd have done better to understand it as "Can InDesign do this on my terms?"
I'm sorry you don't find it useful...
Again, no need. We all have our own ways of working, and if it's useful to you, then I'm glad you were able to get what you wanted in some form.
Copy link to clipboard
Copied
Cool reply, thank you for your interest in this.
Copy link to clipboard
Copied
InDesign doesn't do that by default. But Obi-wan will write you a cool script!
Copy link to clipboard
Copied
Aha!
(^/)
Copy link to clipboard
Copied
Just for fun!
You have this:
… and you want that [4 mm space after resizing]:
… So Play Rock'n Roll! ["undo" in option!]
app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Resize and Distribute! …");
function main()
{
var myDoc = app.activeDocument;
var mySel = app.selection;
if (mySel.length == 0) exit();
else {
var myGroup = myDoc.groups.add(mySel);
var myGB = myGroup.geometricBounds;
myGroup.ungroup();
//---------------------------------- ENTER SPACE (mm) ---------------------------
var mySpace = 4;
var myCalculationW = (myGB[3] - myGB[1] - (((mySel.length) - 1) * mySpace))/(mySel.length) + "mm";
var myNewWidth = UnitValue(myCalculationW).as('pt');
for (i = 0; i < mySel.length; i++) {
var mySelGB = mySel.geometricBounds;
var myCalculationH = (mySelGB[2] - mySelGB[0]) + "mm";
var myCurrentHeight = UnitValue(myCalculationH).as('pt');
if (mySel.geometricBounds[1] == myGB[1]) mySel.resize(CoordinateSpaces.INNER_COORDINATES, AnchorPoint.LEFT_CENTER_ANCHOR, ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH, [myNewWidth, myCurrentHeight]);
if (mySel.geometricBounds[3] == myGB[3]) mySel.resize(CoordinateSpaces.INNER_COORDINATES, AnchorPoint.RIGHT_CENTER_ANCHOR, ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH, [myNewWidth, myCurrentHeight]);
mySel.resize(CoordinateSpaces.INNER_COORDINATES, AnchorPoint.CENTER_ANCHOR, ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH, [myNewWidth, myCurrentHeight]);
}
myDoc.distribute(mySel, DistributeOptions.HORIZONTAL_SPACE, AlignDistributeBounds.ITEM_BOUNDS);
myDoc.align(mySel, AlignOptions.TOP_EDGES, AlignDistributeBounds.ITEM_BOUNDS);
}
}
If 1 click is too much for you, that means you're much lazier than me!
(^/)
Copy link to clipboard
Copied
Always for Fun!
Width and Space equal in the original area! and gift: we choose the new height!
app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Resize and Distribute! …");
function main()
{
var myDoc = app.activeDocument;
var mySel = app.selection;
if (mySel.length == 0) exit();
else {
var myGroup = myDoc.groups.add(mySel);
var myGB = myGroup.geometricBounds;
myGroup.ungroup();
var myCalculation = (myGB[3] - myGB[1])/((mySel.length * 2) - 1) + "mm";
var myNewWidth = UnitValue(myCalculation).as('pt');
var myNewHeight = UnitValue('5mm').as('pt');
for (i = 0; i < mySel.length; i++) {
if (mySel.geometricBounds[1] == myGB[1]) mySel.resize(CoordinateSpaces.INNER_COORDINATES, AnchorPoint.LEFT_CENTER_ANCHOR, ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH, [myNewWidth, myNewHeight]);
if (mySel.geometricBounds[3] == myGB[3]) mySel.resize(CoordinateSpaces.INNER_COORDINATES, AnchorPoint.RIGHT_CENTER_ANCHOR, ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH, [myNewWidth, myNewHeight]);
mySel.resize(CoordinateSpaces.INNER_COORDINATES, AnchorPoint.CENTER_ANCHOR, ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH, [myNewWidth, myNewHeight]);
}
myDoc.distribute(mySel, DistributeOptions.HORIZONTAL_SPACE, AlignDistributeBounds.ITEM_BOUNDS);
myDoc.align(mySel, AlignOptions.TOP_EDGES, AlignDistributeBounds.ITEM_BOUNDS);
}
}
(^/)
Copy link to clipboard
Copied
I agree with John Mensinger. You may get Obi-wan to whip up a script for you, but you're advised to learn the way the program really works out of the box. Unless you want to learn to write JavaScript programs (more power to you if you do!), you won't always have someone around to make one up. Better to learn how to work fast with the tools that are already there.
Copy link to clipboard
Copied
Humm! … Without disturbing, could I have the "10 points"? Thanks!
Siwybiwy, now that it is written, use the script! (even if you don't understand it)!
Copy link to clipboard
Copied
Obi Wan, 10 points. I want this included in InDesign by default!
Copy link to clipboard
Copied
Too specific!
(^/)
Copy link to clipboard
Copied
Thanks Steve, I know all the tricks of alignment and distribution. What inspired me to ask about this is the way ID recalculates the widths of a group of objects when you select and drag one of the handles. Wouldn't it be cool to have an extra control feature that makes them all the same width as you drag? For example, command-control-drag?