-
-
Save zeffii/5b3a4e720a7ed938cc6e 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
def bmesh_from_pydata(verts=[], edges=[], faces=[]): | |
''' verts is necessary, edges/faces are optional ''' | |
if not verts: | |
print("verts data seems empty") | |
return | |
bm = bmesh.new() | |
[bm.verts.new(co) for co in verts] | |
bm.verts.index_update() | |
if faces: | |
for face in faces: | |
bm.faces.new(tuple(bm.verts[i] for i in face)) | |
bm.faces.index_update() | |
if edges: | |
for edge in edges: | |
edge_seq = tuple(bm.verts[i] for i in edge) | |
try: | |
bm.edges.new(edge_seq) | |
except ValueError: | |
# edge exists! | |
pass | |
bm.edges.index_update() | |
return bm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment