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

How can I retrieve all the detailed parameters and constants for InDesign scripting?

Contributor ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

Hello everyone!

When I was searching for information to write scripts for InDesign, I found that some parameters are not easily obtained. For example, I want to resize an object while scaling its strokes and effects. In the Illustrator scripting manual, all the parameters are easily available, such as:

resize
(scaleX,
scaleY
[,changePositions]
[,changeFillPatterns]
[,changeFillGradients]
[,changeStrokePattern]
[,changeLineWidths]
[,scaleAbout])

or

translate
([deltaX]
[,deltaY]
[,transformObjects]
[,transformFillPatterns]
[,transformFillGradients]
[,transformStrokePatterns])

However, the InDesign scripting manual does not provide similar comprehensive script constant parameters. I believe that I might be using the wrong search method or the information I found is incomplete. So, I would like to ask the community for help. How can I access resources for InDesign in this regard and how can I solve the issue of scaling strokes and effects while resizing objects? Thank you!

TOPICS
Scripting

Views

411

Translate

Translate

Report

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 , Jul 20, 2023 Jul 20, 2023

Additionally, is it true that InDesign does not have parameters like Illustrator's Resize, which allows for scaling strokes and effects simultaneously

 

If you want to scale strokes and effects I think you’ll need to look at the transform() method—resize() resizes but doesn’t scale the object. I don‘t do a lot of transformations, so maybe someone else can get help with the details, but here’s a simple example:

 

 

//transform the selected frame
var sel = app.selection[0];

//set stroke and effec
...

Votes

Translate

Translate
Community Expert ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

Hi @Aprking , You can find a comprehensive InDesign API/Object Model here:

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html

 

The application>document page lists the resize() method along with all its parameters:

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PageItem.html#d1e208544__d1e211767

 

Votes

Translate

Translate

Report

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
Contributor ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

Hi @rob day , it's great to see you again. I have looked at the resources you shared, and it seems that my approach to searching for information was incorrect. Additionally, is it true that InDesign does not have parameters like Illustrator's Resize, which allows for scaling strokes and effects simultaneously? How can I achieve scaling effects in InDesign? I apologize for any inconvenience caused and thank you once again

Votes

Translate

Translate

Report

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 ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

Additionally, is it true that InDesign does not have parameters like Illustrator's Resize, which allows for scaling strokes and effects simultaneously

 

If you want to scale strokes and effects I think you’ll need to look at the transform() method—resize() resizes but doesn’t scale the object. I don‘t do a lot of transformations, so maybe someone else can get help with the details, but here’s a simple example:

 

 

//transform the selected frame
var sel = app.selection[0];

//set stroke and effect transform prefs
app.transformPreferences.adjustStrokeWeightWhenScaling = true;
app.transformPreferences.adjustEffectsWhenScaling = true;

//a transform matrix object set to scale
var tm = app.transformationMatrices.add({horizontalScaleFactor:2, verticalScaleFactor:2})
sel.transform(CoordinateSpaces.innerCoordinates, AnchorPoint.leftCenterAnchor, tm);

 

 

And depending on the complexity of the transform you might not need the transform() method—you might simply change the absolute vertical and horizontal scales:

 

 

//transform the selected frame
var sel = app.selection[0];

//set stroke and effect transform prefs
app.transformPreferences.adjustStrokeWeightWhenScaling = true;
app.transformPreferences.adjustEffectsWhenScaling = true;
app.transformPreferences.whenScaling = WhenScalingOptions.ADJUST_SCALING_PERCENTAGE

sel.absoluteHorizontalScale = 200;
sel.absoluteVerticalScale = 200;

 

 

Before and after:

Screen Shot 47.pngexpand imageScreen Shot 48.pngexpand image

 

Votes

Translate

Translate

Report

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
Contributor ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

According to your method, I have successfully scaled the strokes and effects along with the object. However, there is a bug in CC2014 where the stroke weight displayed in the Stroke panel is the same, even though they are actually different. Additionally, the options in the Transform panel do not change with the script.
In CC2023, all of these bugs are completely resolved.
Summary: The resize() method does not support scaling stroke and other parameters. Instead, transform() or Scale should be used. This is different from the resize() function in Illustrator. Please guide me if my understanding is correct.
You are a great teacher, and I appreciate your help once again!error.pngexpand image

Votes

Translate

Translate

Report

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 ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

However, there is a bug in CC2014 where the stroke weight displayed in the Stroke panel is the same

 

You would have to set the .whenScaling property to WhenScalingOptions.APPLY_TO_CONTENT for the stroke to display at its actual size rather than its scaled size

 

 

//transform the selected frame
var sel = app.selection[0];

//set stroke and effect transform prefs
app.transformPreferences.adjustStrokeWeightWhenScaling = true;
app.transformPreferences.adjustEffectsWhenScaling = true;
app.transformPreferences.whenScaling = WhenScalingOptions.APPLY_TO_CONTENT;

//a transform matrix object set to scale
var tm = app.transformationMatrices.add({horizontalScaleFactor:2, verticalScaleFactor:2})
sel.transform(CoordinateSpaces.innerCoordinates, AnchorPoint.leftCenterAnchor, tm);

 

 

Screen Shot 51.pngexpand image

 

 

Votes

Translate

Translate

Report

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
Contributor ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

LATEST

It seems that there are many parameters for the preferences supported in InDesign, which is different from Illustrator. Comparing the differences in script parameters between these two software is an interesting thing. Thanks again!

Votes

Translate

Translate

Report

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 ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

Also, look at the .transformPreference properties, which lets you set stroke and effects scaling for the document:

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#TransformPreference.html

 

Votes

Translate

Translate

Report

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
Contributor ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

A. var transformPrefs = myObject.transformPreferences; retrieves the original properties of the document.

B. When scaling the object, transformPrefs.adjustEffectsWhenScaling = true; is used to specify scaling effects simultaneously.

C. Then, myObject.transformPreferences = transformPrefs; restores the original values.

Is this the correct understanding?

Votes

Translate

Translate

Report

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 ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

var transformPrefs = myObject.transformPreferences; retrieves the original properties of the document.

 

That would throw an error—transformPreferences are a property of the application

Votes

Translate

Translate

Report

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