updated blender mesh dumper to use bmesh module
This commit is contained in:
parent
9521a11854
commit
c1f7ee46bc
50
dump.py
50
dump.py
@ -1,8 +1,50 @@
|
|||||||
import bpy
|
import bpy
|
||||||
|
import bmesh
|
||||||
|
import json
|
||||||
|
|
||||||
|
bpy.data.objects['Cube'].select = True
|
||||||
|
bpy.ops.object.mode_set(mode='EDIT')
|
||||||
|
|
||||||
m = bpy.data.meshes['Cube']
|
m = bpy.data.meshes['Cube']
|
||||||
|
b = bmesh.from_edit_mesh(m)
|
||||||
|
|
||||||
print("verts:", [list(v.co) for v in m.vertices])
|
print("info:")
|
||||||
print("faces:", [list(f.vertices) for f in m.faces])
|
|
||||||
print("edge keys:", [f.edge_keys for f in m.faces])
|
data = {}
|
||||||
print("edges:", [list(e.vertices) for e in m.edges])
|
print("verts:")
|
||||||
|
for vert in b.verts:
|
||||||
|
print(" ", vert.index, ":", list(vert.co))
|
||||||
|
data['vertices'] = [list(vert.co) for vert in b.verts]
|
||||||
|
|
||||||
|
print("edges for vert:")
|
||||||
|
for vert in b.verts:
|
||||||
|
print(" ", vert.index, ":", [e.index for e in vert.link_edges])
|
||||||
|
print("faces for vert:")
|
||||||
|
for vert in b.verts:
|
||||||
|
print(" ", vert.index, ":", [e.index for e in vert.link_faces])
|
||||||
|
|
||||||
|
print("edges:")
|
||||||
|
edges = []
|
||||||
|
for edge in b.edges:
|
||||||
|
print(" ", edge.index, ":", [v.index for v in edge.verts])
|
||||||
|
edges.append([v.index for v in edge.verts])
|
||||||
|
data['edges'] = edges
|
||||||
|
|
||||||
|
print("faces for edge:")
|
||||||
|
for edge in b.edges:
|
||||||
|
print(" ", edge.index, ":", [f.index for f in edge.link_faces])
|
||||||
|
|
||||||
|
|
||||||
|
print("faces:")
|
||||||
|
faces = []
|
||||||
|
for face in b.faces:
|
||||||
|
print(" ", face.index, ":", [v.index for v in face.verts])
|
||||||
|
faces.append([v.index for v in face.verts])
|
||||||
|
data['faces'] = faces
|
||||||
|
|
||||||
|
print("edges for face:")
|
||||||
|
for face in b.faces:
|
||||||
|
print(" ", face.index, ":", [e.index for e in face.edges])
|
||||||
|
|
||||||
|
|
||||||
|
print(json.dumps(data))
|
||||||
|
Loading…
Reference in New Issue
Block a user