""" Moebius Strip 24.04.2020 """ import c4d import math # Variablen und Konstanten dialog_title = 'Moebius Strip' a = 1.5 # Konstante a b = 1.5 # Konstante b m =5 # Konstante m uMin = -0.40 # Bereich u uMax = 0.40 # Bereich u vMin = 0.0 # Bereich v vMax = 2*math.pi # Bereich v Nu = 10 # Anzahl Punkte u Nv = 150 # Anzahl Punkte v Faktor = 100 # Skalierungsfaktor def CreatePolygonObject(): # Polygonobjekt erzeugen obj = c4d.BaseObject(c4d.Opolygon) obj.ResizeObject((Nu+1)*(Nv+1), Nu*Nv) obj.SetName(dialog_title) # Variablen zz=0 # Zaehler # Segmentbreiten berechnen du=(uMax-uMin)/Nu dv=(vMax-vMin)/Nv # Punkte erzeugen for i in xrange(0,Nu+1): for j in xrange(0,Nv+1): # Berechnung der Parameter u=uMin+i*du v=vMin+j*dv # Berechnung der Koordinaten x= (a + u*math.sin(m*v/2))*math.cos(v) z= (b + u*math.sin(m*v/2))*math.sin(v) y= u*math.cos(m*v/2) # Punkt speichern obj.SetPoint(zz, c4d.Vector(x*Faktor,y*Faktor,z*Faktor)) # Zähler erhöhen zz=zz+1 # Polygone erzeugen zz=0 # Zähler zurücksetzen for j in xrange(0,Nv): for i in xrange(0,Nu): # Punkte für ein Quadrat definieren P1=i*(Nv+1)+j P2=i*(Nv+1)+j+1 P3=(i+1)*(Nv+1)+j+1 P4=(i+1)*(Nv+1)+j # Quadrat speichern obj.SetPolygon(zz, c4d.CPolygon(P1,P2,P3,P4)) # Zähler erhöhen zz=zz+1 # obj.Message(c4d.MSG_UPDATE) return obj def main(): plyobj = CreatePolygonObject() doc.InsertObject(plyobj, None, None, True) c4d.EventAdd() if __name__=='__main__': main()