Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import bpy
import bmesh
from bmesh.ops import spin
import math
def lathe_geometry(bm, options, remove_doubles=True, dist=0.0001):
cent, axis, dvec, angle, steps = options
geom = bm.verts[:] + bm.edges[:]
# super verbose explanation.
spin(
bm,
geom=geom, # geometry to use for the spin
cent=cent, # center point of the spin world
axis=axis, # axis, a (x, y, z) spin axis
dvec=dvec, # offset for the center point
angle=angle, # how much of the unit circle to rotate around
steps=steps, # spin subdivision level
use_duplicate=0) # include existing geometry in returned content
if remove_doubles:
bmesh.ops.remove_doubles(bm, verts=bm.verts[:], dist=dist)
def lite_spin(obj, cent=None, axis=(1,0,0), steps=20, angle=2*math.pi):
dvec = (0,0,0) # rarely used, but handy
bm = bmesh.new()
bm.from_mesh(obj.data)
if not cent:
cent = obj.location
options = cent, axis, dvec, angle, steps
lathe_geometry(bm, options)
bm.to_mesh(obj.data)
bm.free()
obj = bpy.data.objects['Profile']
lite_spin(obj, steps=20, angle=math.pi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.