Alright, we can even get an [object Polygon] when we are using the result of the subtractPath() method as a blueprint:
var doc = app.documents.add();
/*
Create a "circle"-like oval on the page.
Why "circle"-like? See:
A Primer on Bézier Curves
§42 Circular arcs and cubic Béziers
https://pomax.github.io/bezierinfo/#circles_cubic
*/
var oval = doc.spreads[0].ovals.add
(
{
geometricBounds : [ 0, 0, 100, 100 ] ,
strokeWeight : 0 ,
strokeColor : "None" ,
fillColor : "None"
}
);
/*
Create a rectangle that overlaps the oval:
*/
var rectangle = doc.spreads[0].rectangles.add
(
{
geometricBounds : [ -10, 50, 110, 110 ] ,
strokeWeight : 0 ,
strokeColor : "None" ,
fillColor : "None"
}
);
// Use substractPath() method.
// ISSUE: The returned object is still of type [object Oval]
var bluePrint = rectangle.subtractPath
(
[ oval ]
);
// We could correct that by adding a polygon
// and clone the entirePath of the result, the bluePrint, to the polygon:
var polygon = doc.spreads[0].polygons.add
(
{
strokeWeight : 0 ,
strokeColor : "None" ,
fillColor : "None"
}
);
polygon.paths[0].entirePath = bluePrint.paths[0].entirePath;
//The blueprint is not needed anymore:
bluePrint.remove();
Regards,
Uwe Laubender
( ACP )