import blender from blender import * import math obj = mesh.new("object") obj2 = mesh.get("sphere") cubeverts = obj2.verts #defining variables punktid = [] selected_faces = [] seledges = [] edge = obj.edges verts = obj.verts faces = obj.faces radians=math.radians selected = [] sin=math.sin degrees = math.degrees asin = math.asin sqrt = math.sqrt cos = math.cos abs = math.fabs #data of circle raadius = 0 oval = 90 resolution = 10 center = 0 coilhight = 2 nrofrotations=8 #/data of circle vertspercoil = (len(verts)/len(cubeverts)) def vector(v1,v2): vect = sqrt((v1[0]-v2.co[0]*v1[0]-v2.co[0])+(v1[1]-v2.co[1]*v1[1]-v2.co[1])) return vect def vector2to3(v1,v2): vect = v1[2]+v2.co[2] return vect def circle(centershiftx,centershifty,oval,resolution,center,steps,shiftx,shifty,shiftz ,hightshift,radius): count = 0 centerz = 1 while count < steps: sektor = 0 count +=1 stepz = 0 stepx = oval sektor = 1 centerx = 1 centery = 1 while sektor < 2: if sektor == 1: centerx = centerx + raadius*sin(radians(stepx)) centery = centery + raadius*sin(radians(stepz)) centerz = centerz+(coilhight/100.00)
verts.extend(((centershifty+radius)*sin(radians(stepz))),((centershiftx+radius)*si n(radians(stepx)))+(centershifty*sin(radians(stepx))),centerz+hightshift) stepz +=resolution stepx +=-1*resolution if stepz >= 360: sektor = 2 for i in range(0,len(cubeverts)): currentvertx = cubeverts[i].co[0] currentverty = cubeverts[i].co[1] currentvertz = cubeverts[i].co[2] centershiftx = 0-cubeverts[i].co[0] centershifty = 0-cubeverts[i].co[1] hightshift = (vector2to3([0.1,0.1,0.1],cubeverts[i])) circle(centershiftx,centershifty,oval,10,0,nrofrotations,currentvertx,currentverty ,currentvertz,hightshift,raadius) #filling jump = (len(verts)/len(cubeverts)) delface = 0 delface +=jump print "jump ",jump for v in verts: v.sel = 0 for i in range(0,len(verts)-1): if (i+(len(verts)/len(cubeverts))+1 < len(verts)) and ( i < (len(verts)/(len(cubeverts))*(len(cubeverts)-1))): if i !=delface-1: vert1=i vert2=i+1 vert3=i+(len(verts)/len(cubeverts))#(len(verts)/len(cubeverts)) verts per ring vert4=i+(len(verts)/len(cubeverts))+1 faces.extend(vert2,vert4,vert3,vert1) if i == delface: print "delface",delface verts[delface].sel = 1 delface += jump elif (i <= (len(verts)-1)) and (i(len(verts)/(len(cubeverts))*(len(cubeverts)-1))>=0): if i !=delface-1: vert1=i vert2=i+1 vert3=i-(len(verts)/(len(cubeverts))*(len(cubeverts)1))#(len(verts)/len(cubeverts)) verts per ring vert4=(i+1)-(len(verts)/(len(cubeverts))*(len(cubeverts)-1)) faces.extend(vert2,vert4,vert3,vert1) if i == delface: delface = delface+jump scn = scene.getcurrent() ob = scn.objects.new(obj,"coil") ob = scn.objects.new(obj2,"coil2") blender.redraw()