Hi,
I created a quick-and-dirty, -but functional- script to add disc-segments with height to the scene. It has no gui and runs straight from the text-editior. The parameters can directly be changed within the script. (Maybe I’ll put it in a decent gui once upon a time :rolleyes: )
Here´s the script:
from Blender import *
import bpy
import math
editmode = Window.EditMode()
if editmode: Window.EditMode(0)
#parameters
startAngle=0.0
stopAngle=70.0
divs=20
innerRadius=7
outerRadius=8
height=6
#end of parameters
incAngle = (stopAngle - startAngle) / divs
print incAngle
#initiated
innerCircle=[]
outerCircle=[]
coords=[]
faces=[]
# CALCULATE COORDINATES IN INNER AND OUTER CIRCLE
for n in range(0,divs+1):
alpha = startAngle + n * incAngle
teta = alpha * 2 * pi/360
#calculate inner circle
x = innerRadius * math.cos(teta)
y = innerRadius * math.sin(teta)
innerCircle.append([x,y])
#calculate outer circle
x = outerRadius * math.cos(teta)
y = outerRadius * math.sin(teta)
outerCircle.append([x,y])
# CALCULATE MESH POINTS
for n in range (len(innerCircle)):
coords.append([innerCircle[n][0],innerCircle[n][1],0])
coords.append([outerCircle[n][0],outerCircle[n][1],0])
coords.append([outerCircle[n][0],outerCircle[n][1],height])
coords.append([innerCircle[n][0],innerCircle[n][1],height])
me = bpy.data.meshes.new('myMesh') # create a new mesh
# CALCULATE FACES
for n in range (len(innerCircle)-1):
p=n*4
q=n*4+4
#bottom faces
faces.append([p+0,p+1,q+1,q+0])
#outer faces
faces.append([q+1,q+2,p+2,p+1])
#top faces
faces.append([p+2,p+3,q+3,q+2])
#inner faces
faces.append([q+3,q+0,p+0,p+3])
#frontal closing face
faces.append([0,1,2,3])
#back closing face
faces.append([q+3,q+2,q+1,q+0])
#me.verts.extend(surface) # add vertices to mesh
me.verts.extend(coords) # add vertices to mesh
me.faces.extend(faces) # add faces to the mesh (also adds edges)
scn = bpy.data.scenes.active # link object to current scene
ob = scn.objects.new(me, 'myObj')
if editmode: Window.EditMode(1)