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";
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
...
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";
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 )
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?
Copy link to clipboard
Copied
ScriptPreferences is a property of the application:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ScriptPreference.html#d1e335803
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html
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";
Copy link to clipboard
Copied
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 )