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

Scripting: Creating an Oval with specific size

New Here ,
Apr 19, 2021 Apr 19, 2021

Copy link to clipboard

Copied

Hello Everyone,

 

I'm reading through the documentation and relevant posts but I don't fully understand the geometricBounds attribute for creating an oval.

 

Basically, I need to create registration dots in the document bleed in each corner and each dot should be .25".  

 

Each time I add the circle with the code below, I get a super small circle on the artboard.

 

Need it to be .25" no matter the size of the current document.

Do I need a reference to the current page size to do this somehow?

 

var cr = app.activeDocument.pages[0].ovals.add();
cr.geometricBounds = [-.25,0,0,.25];
cr.fillColor = "Black";

 

TOPICS
Scripting

Views

354

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 2 Correct answers

Community Expert , Apr 19, 2021 Apr 19, 2021

Hi icallender,

you'll get that super small circle because you did not provide any meassuerment system.

InDesign is following your rulers' systems. If your rulers say Points you'll get Points. If your rulers say Millimeters you'll get Millimeters. You could change the rulers by scripting or you could provide strings that express inches. As you can guess from the code below you also could mix measurement units when using strings:

 

Suggested code:

 

app.activeDocument.pages[0].ovals.add
(
	{
		geo
...

Votes

Translate

Translate
Community Expert , Apr 19, 2021 Apr 19, 2021

Also, you can set the measurement units for just the script (so you don’t have to set and reset ruler units):

 

app.scriptPreferences.measurementUnit = MeasurementUnits.INCHES

var cr = app.activeDocument.pages[0].ovals.add();
cr.geometricBounds = [-.25,0,0,.25];
cr.fillColor = "Black";

  

Votes

Translate

Translate
Community Expert ,
Apr 19, 2021 Apr 19, 2021

Copy link to clipboard

Copied

Hi icallender,

you'll get that super small circle because you did not provide any meassuerment system.

InDesign is following your rulers' systems. If your rulers say Points you'll get Points. If your rulers say Millimeters you'll get Millimeters. You could change the rulers by scripting or you could provide strings that express inches. As you can guess from the code below you also could mix measurement units when using strings:

 

Suggested code:

 

app.activeDocument.pages[0].ovals.add
(
	{
		geometricBounds : [ "-.25 In",0,0,".25 In" ] ,
		fillColor : "Black" ,
		strokeWeight : 0 ,
		strokeColor : "None"
	}
);

 

Regards,
Uwe Laubender

( ACP )

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
New Here ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Ahhh, did not see that in any docs I was looking at.  Very helpful to know I can set the measurementUnit on the doc.  Thanks!  Is there documentation that spells this out this somewhere?

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 ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

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 ,
Apr 19, 2021 Apr 19, 2021

Copy link to clipboard

Copied

Also, you can set the measurement units for just the script (so you don’t have to set and reset ruler units):

 

app.scriptPreferences.measurementUnit = MeasurementUnits.INCHES

var cr = app.activeDocument.pages[0].ovals.add();
cr.geometricBounds = [-.25,0,0,.25];
cr.fillColor = "Black";

  

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 ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

LATEST

Also keep in mind that your values in that array of the geometric bounds are related to the zero point.

And be prepared for a little shock if it happens that the spread view is rotated by e.g. 180°. If you are in total control of the document there is not much reason to care about it, but if you are working with arbitrary documents from customers you have to keep that in mind.

 

Regards,
Uwe Laubender

( ACP )

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