You are on page 1of 2

#rainer plumer

import blender
import math
from blender import *
from blender import window, text, draw, bgl
from blender.window import *
from blender.text import *
from blender.draw import *
from blender.bgl import *
from blender import nmesh #lots of useless modules imported
window.editmode(1)
scn = scene.getcurrent()
mesh = nmesh.getraw()
obj = mesh.new("circle")
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
#andmed ringi kohta
ringidearv = 4 #number of subcircles
resolutsioon = 7 #the smaller number the more verts per circle
ovalness = 90 #90 is perfect circle,the lower, the more oval
center = 0 #center point of circle
raadius=6 #radius of circle
raadiusini = 0 #dont change this
#/andmed ringi kohta

def vector(v1,v2):#gets the distance between two points,not used in this script
vect = sqrt((v1.co[0]-v2.co[0])*(v1.co[0]-v2.co[0])+(v1.co[1]-
v2.co[1])*(v1.co[1]-v2.co[1])+(v1.co[2]-v2.co[2])*(v1.co[2]-v2.co[2]))
return vect

def circle(raadius,oval,resolution,center):#makes a circle


stepz = 0
stepx = oval
sektor = 1
while sektor < 2:
if sektor == 1:
verts.extend(center-
raadius*sin(radians(stepz)),center+raadius*sin(radians(stepx)),0)
stepz +=resolution
stepx +=-1*resolution
if stepz >= 360:
sektor = 2
stepraadius = (raadius+0.0)/ringidearv
for i in range(1,ringidearv+1): #makes all the circles
circle(raadiusini,ovalness,resolutsioon,center)
raadiusini = raadiusini+stepraadius
vertsincircle = (len(verts)/ringidearv)
jump = 1#dont change this,when filling a circle reaches to an end, it jumps to
next circle
for i in range(0,(vertsincircle)*ringidearv+1):
if i+(vertsincircle+1)<len(verts) and (i<>jump*(vertsincircle-1)+jump-1) :
vert1=i
vert2=i+1
vert3=vertsincircle+i
vert4=(vertsincircle+1)+i #tavaline ring <>
faces.extend(vert1,vert2,vert4,vert3)
if i == ((jump * (vertsincircle-1))+jump-1) and(i+(vertsincircle-
2)<len(verts)):
vert1=i
vert2=i+1
vert3=i-(vertsincircle-1)
vert4=i+vertsincircle
jump +=1
faces.extend(vert1,vert4,vert2,vert3)
verts.extend(center,center,0)
centervert = len(verts)-1
#fill the center
for i in range(0,(vertsincircle)):
if i < (vertsincircle-1):
faces.extend(i,i+1,centervert)
if i == (vertsincircle-1):
faces.extend(i,0,centervert)
ob = scn.objects.new(obj,"circle")
blender.redraw()

You might also like