Skip to main content
zeRafio
Inspiring
September 7, 2024
Question

Problem with 'resize' command

  • September 7, 2024
  • 1 reply
  • 1091 views

My question is about Applescript but I think the issue is the same with Javascript.

 

Can someone confirm that in InDesign 19.5.1 this snippet errors when applied on a vertical graphic line:

 

resize someLine in outer stroke bounds from top left anchor by replacing current dimensions with values {3, 70} 

 

 The same goes with a horizontal graphic line with inverted values {70, 3}

[error 11269 : the requested value is not an allowed dimension]

This topic has been closed for replies.

1 reply

m1b
Community Expert
Community Expert
September 7, 2024

Hi @zeRafio, I can confirm this error in ExtendScript:

 

I mean... it makes sense, right? A vertical line has no width—it has zero width, and moreover it can't have width. So the error makes perfect sense.

 

You can see this happening here:

graphicLine.resize(
    CoordinateSpaces.PARENT_COORDINATES,
    AnchorPoint.TOP_LEFT_ANCHOR,
    ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY,
    [1, 4]
);

This operation works fine, without error, on a vertical line, because it isn't trying to change the width. But this will throw the error:

graphicLine.resize(
    CoordinateSpaces.PARENT_COORDINATES,
    AnchorPoint.TOP_LEFT_ANCHOR,
    ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY,
    [1.1, 4]
);

 Are you trying to achieve something? Are you trying to avoid this error? Or just curious? Maybe you should work with a Rectangle rather than a GraphicLine?

- Mark

zeRafio
zeRafioAuthor
Inspiring
September 7, 2024

Thanks for confirming, @m1b 

 

I'm pretty sure the command was working in the past.

Here is an screenshot of the applescript dictionary of indy 19.5.1:

So you should be able to modify the visible bounds of a graphic line, wright?

Try it, it will trigger the same error.

 

I'm using a transformation matrix.

But here I get a second issue: stroke weight is not changed.

 

set scaleMatrix to make transformation matrix with properties {horizontal scale factor:rateH, vertical scale factor:rateV}
transform aBox in parent coordinates from top left anchor with matrix scaleMatrix

 

So I have to add a 'set stroke weight to…' command.

 

If you have a better solution, I'm interested.

m1b
Community Expert
Community Expert
September 7, 2024

Hi @zeRafio, yes sorry I should have realised what you wanted. So you are seeing the different meaning that the `resize` method has, versus the `transform` method. It is reflected in the normal UI: try to "resize" a vertical line via the UI—you can't. But you can scale it. Same with scripting.

 

So the following works fine, and doubles the stroke weight:

var doc = app.activeDocument;
var verticalLine = doc.selection[0];

app.transformPreferences.properties = {
    adjustStrokeWeightWhenScaling: true,
    dimensionsIncludeStrokeWeight: true,
    whenScaling: WhenScalingOptions.APPLY_TO_CONTENT,
};

var tm = app.transformationMatrices.add({
    horizontalScaleFactor: 2,
    verticalScaleFactor: 2,
});

verticalLine.transform(
    CoordinateSpaces.pasteboardCoordinates,
    AnchorPoint.centerAnchor,
    tm,
);

 

If your stroke didn't scale, then you might have a different "adjustStrokeWeightWhenScaling" setting.

 

The `transform` method is the best way to scale things, generally in Indesign scripts, I think. "Resize" is a special case for certain objects, and if they can't be resized via the UI, then scripting won't help, most likely.

- Mark