-
-
Save zeffii/d4efc7c346d6aa90ae18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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