Copy link to clipboard
Copied
Good morning,
I'm wondering, how to resize an rectangle in only one direction by script, to acheive identical result, as mouse double clikin on the middle handle ?
the fit() method doesn't allow to do such operation, I think ?
thanks in advance for suggestions or solution 🙂
many regards a.
Copy link to clipboard
Copied
Hi platm72,
Auto sizing options is available for text frames not for rectangles like:
var myTextFrame = app.activeDocument.pages[0].textFrames[0];
/// These are four types ======
myTextFrame.textFramePreferences.autoSizingType = AutoSizingTypeEnum.OFF;
myTextFrame.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_AND_WIDTH;
myTextFrame.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_AND_WIDTH_PROPORTIONALLY;
myTextFrame.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY;
myTextFrame.textFramePreferences.autoSizingType = AutoSizingTypeEnum.WIDTH_ONLY;
/// ==========================
Unforutnately there's no such thing for rectangles
Here are some list how you can fit rectangle frames :
var myRectangle = app.activeDocument.pages[0].rectangles[0];
//// These are types how you can fit you rectangle frames ======
myRectangle.fit(FitOptions.APPLY_FRAME_FITTING_OPTIONS);
myRectangle.fit(FitOptions.CENTER_CONTENT);
myRectangle.fit(FitOptions.CONTENT_AWARE_FIT);
myRectangle.fit(FitOptions.CONTENT_TO_FRAME);
myRectangle.fit(FitOptions.FILL_PROPORTIONALLY);
myRectangle.fit(FitOptions.FRAME_TO_CONTENT);
myRectangle.fit(FitOptions.PROPORTIONALLY);
/// ==========================================================
You can have more information here on rectangles : Rectangle && Rectangles
Best
Sunil
Copy link to clipboard
Copied
FitOptions.CONTENT_AWARE_FIT===This is not supported===
Best
Sunil
Copy link to clipboard
Copied
Hi,
A method you can use is Resize - https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Rectangle.html#d1e217105
Which is a little complicated when you first look at it.
undefined resize (in:Varies BoundingBoxLimits CoordinateSpaces BoundsKind:BoundingBoxLimits OrderedarraycontainingcoordinateSpace:CoordinateSpaces, from:Array of Varies AnchorPoint AnchorPoints 2 Reals BoundingBoxLimitss CoordinateSpacess Arrays of 2 Reals LongIntegers, by:ResizeMethods, values:Array of Varies Reals ResizeConstraintss CoordinateSpacess, [resizeIndividually:Boolean=Boolean], [consideringRulerUnits:Boolean=Boolean])
but with a little trial and error you should be able to work out what works for you. I would try something like
myRectangle.resize (BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS,
AnchorPoint.CENTER_ANCHOR,
ResizeMethods.ADDING_CURRENT_DIMENSIONS_TO, [100, 100], false, false);
Note: I am not in a position to test this so it may not run out of the box, and it will resize your rectangle in both directions, to alter that just change the value of the 100.
Hope this helps.
Malcolm
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more