Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from anonymous/lathe_utils.py
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/2baad5aacd496dc9a0cc to your computer and use it in GitHub Desktop.
Save zeffii/2baad5aacd496dc9a0cc to your computer and use it in GitHub Desktop.
import mathutils
from mathutils import Vector
import bmesh
import sv_bmesh_utils
from sv_bmesh_utils import bmesh_from_pydata
def sv_main(verts=[[]], edges=[[]], origins=[[]], normals=[[]], radians=1.0, segments=20):
in_sockets = [
['v', 'verts', verts],
['s', 'edges', edges],
['v', 'origins', origins],
['v', 'normals', normals],
['s', 'radians', radians],
['s', 'segments', segments]]
out_sockets = [
['v', 'Vecs', []],
['s', 'Polys', []]
]
if not verts or not verts[0]:
return in_sockets, out_sockets
# defend against div by zero
segments = max(segments, 1)
print(origins, normals)
cent = Vector((0,0,0))
axis = Vector((0,0,1))
dvec = Vector((0,0,0))
angle = radians
space = mathutils.Matrix()
steps = segments
use_duplicate = False
bm = bmesh_from_pydata(verts[0], edges[0], [])
geom = bm.verts[:] + bm.edges[:]
bmesh.ops.spin(bm,
geom=geom, cent=cent, axis=axis,
dvec=dvec, angle=radians,
space=space,
steps=segments,
use_duplicate=use_duplicate)
v = [v.co[:] for v in bm.verts]
p = [[i.index for i in p.verts] for p in bm.faces[:]]
bm.free()
out_sockets[0][2] = v
out_sockets[1][2] = p
return in_sockets, out_sockets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment