I would like to programmatically create and extrude polygons. I've found several examples of code (e.g. here), but none of them are currently working for me. As a simple example, I am trying to get things working first with a defined circular face and then extrude that face. Here is the code defining the circular bmesh:
import bpy, bmesh from math import * NUMVERTS = 1000 Dphi = 2*pi/NUMVERTS # calculate x,y coordinate pairs coords = [(cos(i*Dphi),sin(i*Dphi),0) for i in range(NUMVERTS)] bm = bmesh.new() for v in coords: bm.verts.new(v) bm.faces.new(bm.verts) bm.normal_update() me = bpy.data.meshes.new("circle") bm.to_mesh(me) # add bmesh to scene ob = bpy.data.objects.new("circle",me) bpy.context.scene.objects.link(ob) bpy.context.scene.update()
Which results in a 2D circle
I then want to extrude that face in z by some amount resulting in something like:
I would like to do everything in a python script without having to select anything in the GUI. Also, I'm using a circle as a placeholder example here -- I ultimately want to import much more complicated 2D (XY) polygons and extrude them in Z by some amount. Thanks!