*On 22/08/2017 at 12:14, xxxxxxxx wrote:*

Hello PluginCafe,

I have written a small script, which creates supershapes (based on a sphere).

So far so good, I can calculate all the points of my object but I don't know why,

but when it comes to calculating the polygons I just don't get it right.

I know this is not that sdk related or anything, but it's my first time building an object

and it would help me for future reference aswell.

```
import c4d
import math
from c4d import gui
#Welcome to the world of Python
#constants
a = 1
b = 1
m = 0
n1 = 1
n2 = 1
n3 = 1
def supershapeRAD(theta, m, n1, n2, n3) :
"""Calculates the radius of the supershape from a given theta (lon/lat) and some defined constants"""
t1 = math.fabs((1/a)*math.cos(m*theta/4))
t1 = math.pow(t1, n2)
t2 = math.fabs((1/b)*math.sin(m*theta/4))
t2 = math.pow(t2, n3)
t3 = t1+t2
r = math.pow(t3, -1/n1)
return r
def main() :
total = 20 # number of points
rad = 200 #base radius of the sphere
obj = c4d.PolygonObject(total*total, total*total) #create a new polygon object
counter = 0 #counter for polygons
for i in xrange(total-1) :
lat = c4d.utils.RangeMap(i, 0, total, -math.pi/2, math.pi/2, False) #map latitude to -pi/2 pi/2
r2 = supershapeRAD(lat, m, n1, n2, n3) #calculate first supershape radius
for j in xrange(total) :
lon = c4d.utils.RangeMap(j, 0, total, -math.pi, math.pi, False) #map londitude to -pi pi
r1 = supershapeRAD(lon, m, n1, n2, n3) #calculate second supershape radius
#calculate position (x,y,z) of the points
x = rad *r1* math.cos(lon) * r2*math.cos(lat)
y = rad *r1* math.sin(lon) * r2*math.cos(lat)
z = rad *r2* math.sin(lat)
obj.SetPoint(j+i*total, c4d.Vector(x,y,z)) #set the point
#This is the part that gives me trouble
#obj.SetPolygon(counter, c4d.CPolygon(a,b,c))
counter += 1
obj.Message(c4d.MSG_UPDATE)
doc.InsertObject(obj)
c4d.EventAdd()
if __name__=='__main__':
main()
```

This is my current code, it is able to calculate the necessary points.

I have already looked into the PyRoundedTube example, but that doesn't really help me.

I hope somebody can help me, because I feel really stupid right now

greetings,

Florian