-
-
Save zeffii/e44077fcf86cfbf65dba 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 mathutils | |
from mathutils import Vector | |
import bmesh | |
import sv_bmesh_utils | |
from sv_bmesh_utils import bmesh_from_pydata | |
def sv_main(verts=[[]], edges=[[]], cent=[[]], axis=[[]], dvec=[[]], space=[[]], angle=2.0, steps=20): | |
in_sockets = [ | |
['v', 'verts', verts], | |
['s', 'edges', edges], | |
['v', 'cent', cent], | |
['v', 'axis', axis], | |
['v', 'dvec', dvec], | |
['m', 'matrix', space], | |
['s', 'angle', angle], | |
['s', 'steps', steps] | |
] | |
out_sockets = [ ['v', 'Vecs', []], ['s', 'Polys', []] ] | |
if not verts or not verts[0]: | |
return in_sockets, out_sockets | |
# defend against div by zero | |
use_duplicate = False | |
steps = max(steps, 1) | |
cent = Vector(cent[0][0]) if (cent and cent[0]) else Vector() | |
axis = Vector(axis[0][0]) if (axis and axis[0]) else Vector((0,0,1)) | |
dvec = Vector(dvec[0][0]) if (dvec and dvec[0]) else Vector() | |
space = Matrix(space[0]) if (space and space[0]) else Matrix() | |
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=angle, | |
space=space, steps=steps, 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