Hey,

This is probably (hopefully) a very simple question, but which seems to be harder to find an answer for than it should.

I would like to draw star polygons with python (GHpython), but I can’t seem to find the command for it. Whats the Rhinocommon command for creating n-sided polygons? Is the polygon tools a macro of other commands?

Many thanks

/Jakob

Alright, no time for waiting, so here’s a simple solution for a ngon in case any1 else needs it:

```
def polygon(n):
sector = math.pi * 2 / n
return [Rhino.Geometry.Point3d(
math.sin(sector * i),
math.cos(sector * i),
0
) for i in range(n)]
```

and heres the whole thing to make a star:

```
import Rhino
import math
from itertools import chain
n = int(n)`
def polygon(n, radii, rotation=0):
sector = math.pi * 2 / n
return [Rhino.Geometry.Point3d(
math.sin((sector * i) + rotation) * radii,
math.cos((sector * i) + rotation) * radii,
0
) for i in range(n)]
def star(n, r1, r2):
polyline = []
for i in zip(polygon(n, r1), polygon(n, r2, rotation=(math.pi * 2 / n) / 2)):
polyline.extend(i)
return Rhino.Geometry.PolylineCurve(polyline + [polyline[0]])
star = star(n, r1, r2)
```

Hi @Jakob1,

I’m surprised we haven’t exposed method to do this. I’ve added a to-do item to the pile.

https://mcneel.myjetbrains.com/youtrack/issue/RH-48105

– Dale

1 Like