Skip to main content
January 16, 2021
Answered

How do you make a circle that is divided into 300 pieces of cake of equal size?

  • January 16, 2021
  • 2 replies
  • 487 views

Can someone explain to me which steps it need? 

This topic has been closed for replies.
Correct answer femkeblanco

You can try this script.

var d = app.activeDocument.artboards[0].artboardRect;
var paths = app.activeDocument.pathItems;
var circle1 = paths.ellipse(d[3]/2+250, d[2]/2-250, 500, 500);
var polygon1 = paths.polygon(d[2]/2, d[3]/2, 250, 300);
var points1 = polygon1.pathPoints;
for (var i = 0; i < points1.length/2; i++) {
    var line1 = paths.add();
    var points2 = [points1[i].anchor, points1[i+150].anchor];
    line1.setEntirePath(points2);
}
polygon1.remove();

2 replies

femkeblanco
femkeblancoCorrect answer
Legend
January 16, 2021

You can try this script.

var d = app.activeDocument.artboards[0].artboardRect;
var paths = app.activeDocument.pathItems;
var circle1 = paths.ellipse(d[3]/2+250, d[2]/2-250, 500, 500);
var polygon1 = paths.polygon(d[2]/2, d[3]/2, 250, 300);
var points1 = polygon1.pathPoints;
for (var i = 0; i < points1.length/2; i++) {
    var line1 = paths.add();
    var points2 = [points1[i].anchor, points1[i+150].anchor];
    line1.setEntirePath(points2);
}
polygon1.remove();
January 16, 2021

Great, thanks! I tried the script and it works perfect. Can you explain to me how I can change the pieces from 300 to another number?

femkeblanco
Legend
January 16, 2021
var n = prompt("Enter even number ≥ 4", 4, "Number of circular sectors");
var d = app.activeDocument.artboards[0].artboardRect;
var paths = app.activeDocument.pathItems;
var circle1 = paths.ellipse(d[3]/2+250, d[2]/2-250, 500, 500);
var polygon1 = paths.polygon(d[2]/2, d[3]/2, 250, n);
var points1 = polygon1.pathPoints;
for (var i = 0; i < points1.length/2; i++) {
    var line1 = paths.add();
    var points2 = [points1[i].anchor, points1[i+n/2].anchor];
    line1.setEntirePath(points2);
}
polygon1.remove();
Ton Frederiks
Community Expert
Community Expert
January 16, 2021

Try the Polar Grid tool (hidden below the Line Segment tool)