Created
February 25, 2015 11:07
-
-
Save zeffii/71862f5b1cad1bf1d2c1 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 mathutils import Matrix, Vector | |
def getDupliEdges(edges): | |
dupEdges = [] | |
for e in edges: | |
retOneEdge = bmesh.ops.duplicate(bm, geom=[e]) | |
dupGeom = retOneEdge["geom"] | |
dupEdge = [j for j in dupGeom if isinstance(j, bmesh.types.BMEdge)] | |
dupEdges.append(dupEdge[0]) | |
# now we're done with the original edges, we can deselect | |
for edge in edges: | |
edge.select = False | |
# select the new ones. | |
for edge in dupEdges: | |
edge.select = True | |
return dupEdges | |
def scaleEdges(dupEdges,factor): | |
for e in dupEdges: | |
mid_invert = (e.verts[0].co + e.verts[1].co) * -0.5 | |
edge_matrix = Matrix() | |
edge_matrix[0][3] = mid_invert[0] | |
edge_matrix[1][3] = mid_invert[1] | |
edge_matrix[2][3] = mid_invert[2] | |
bmesh.ops.scale(bm, vec=factor, space=edge_matrix, verts=e.verts) | |
obj = bpy.context.edit_object | |
mesh = obj.data | |
bm = bmesh.from_edit_mesh(mesh) | |
bm.faces.active = None | |
edges = [e for e in bm.edges if e.select] | |
dupEdges = getDupliEdges(edges) | |
scaleEdges(dupEdges, factor=[2.0, 2.0, 2.0]) | |
bmesh.update_edit_mesh(mesh, True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment