Answered
Scissors tool via script
I need to create a half circle and I think the best way is with the scissors tool. The problem is when I want to do it via script. I can't find anything that can guide me.
Thank you very much.
I need to create a half circle and I think the best way is with the scissors tool. The problem is when I want to do it via script. I can't find anything that can guide me.
Thank you very much.
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 )
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.