-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
dumpmesh.py
213 lines (173 loc) · 20 KB
/
dumpmesh.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# ##### BEGIN GPL LICENSE BLOCK #####
#
# DumpMesh, a Blender addon
# (c) 2016-2019 Michel J. Anders (varkenvarken)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "DumpMesh",
"author": "Michel Anders (varkenvarken)",
"version": (0, 0, 201909011717),
"blender": (2, 80, 0),
"location": "View3D > Object > DumpMesh",
"description": "Dumps geometry information of active object in a text buffer",
"warning": "",
"wiki_url": "https://github.com/varkenvarken/blenderaddons/blob/master/dumpmesh.py",
"tracker_url": "",
"category": "Object"}
# to prevent problems with all sorts of quotes and stuff, the code that will be included in the final output is here base64 encoded
# you can find the readable version on https://github.com/varkenvarken/blenderaddons/blob/master/createmesh%20.py
GPLblurb = b'IyAjIyMjIyBCRUdJTiBHUEwgTElDRU5TRSBCTE9DSyAjIyMjIwojCiMgIENyZWF0ZU1lc2gsIGEgQmxlbmRlciBhZGRvbgojICAoYykgMjAxNi0yMDE5IE1pY2hlbCBKLiBBbmRlcnMgKHZhcmtlbnZhcmtlbikKIwojICBUaGlzIHByb2dyYW0gaXMgZnJlZSBzb2Z0d2FyZTsgeW91IGNhbiByZWRpc3RyaWJ1dGUgaXQgYW5kL29yCiMgIG1vZGlmeSBpdCB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlCiMgIGFzIHB1Ymxpc2hlZCBieSB0aGUgRnJlZSBTb2Z0d2FyZSBGb3VuZGF0aW9uOyBlaXRoZXIgdmVyc2lvbiAyCiMgIG9mIHRoZSBMaWNlbnNlLCBvciAoYXQgeW91ciBvcHRpb24pIGFueSBsYXRlciB2ZXJzaW9uLgojCiMgIFRoaXMgcHJvZ3JhbSBpcyBkaXN0cmlidXRlZCBpbiB0aGUgaG9wZSB0aGF0IGl0IHdpbGwgYmUgdXNlZnVsLAojICBidXQgV0lUSE9VVCBBTlkgV0FSUkFOVFk7IHdpdGhvdXQgZXZlbiB0aGUgaW1wbGllZCB3YXJyYW50eSBvZgojICBNRVJDSEFOVEFCSUxJVFkgb3IgRklUTkVTUyBGT1IgQSBQQVJUSUNVTEFSIFBVUlBPU0UuICBTZWUgdGhlCiMgIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlIGZvciBtb3JlIGRldGFpbHMuCiMKIyAgWW91IHNob3VsZCBoYXZlIHJlY2VpdmVkIGEgY29weSBvZiB0aGUgR05VIEdlbmVyYWwgUHVibGljIExpY2Vuc2UKIyAgYWxvbmcgd2l0aCB0aGlzIHByb2d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bWUudXBkYXRlKCkKCQkJYm0uZnJlZSgpCgoJCQkjIGFzc29jaWF0ZSB0aGUgbWVzaCB3aXRoIHRoZSBvYmplY3QKCQkJb2IuZGF0YSA9IG1lCgoJCQljb250ZXh0LnZpZXdfbGF5ZXIub2JqZWN0cy5hY3RpdmUgPSBvYgoJCQlvYi5zZWxlY3Rfc2V0KFRydWUpCgoJCXJldHVybiB7J0ZJTklTSEVEJ30KCmRlZiByZWdpc3RlcigpOgoJYnB5LnV0aWxzLnJlZ2lzdGVyX2NsYXNzKENyZWF0ZU1lc2gpCglicHkudHlwZXMuVklFVzNEX01UX2FkZC5hcHBlbmQobWVudV9mdW5jKQoKZGVmIHVucmVnaXN0ZXIoKToKCWJweS51dGlscy51bnJlZ2lzdGVyX21vZHVsZShDcmVhdGVNZXNoKQoJYnB5LnR5cGVzLlZJRVczRF9NVF9hZGQucmVtb3ZlKG1lbnVfZnVuYykKCmRlZiBtZW51X2Z1bmMoc2VsZiwgY29udGV4dCk6CglzZWxmLmxheW91dC5vcGVyYXRvcihDcmVhdGVNZXNoLmJsX2lkbmFtZSwgaWNvbj0nUExVR0lOJykKCmlmIF9fbmFtZV9fID09ICJfX21haW5fXyI6CglyZWdpc3RlcigpCg=='
import bpy
import bmesh
from bpy.props import BoolProperty, StringProperty, IntProperty
from base64 import standard_b64decode as b64decode
class DumpMesh(bpy.types.Operator):
"""Dumps mesh geometry information to a text buffer"""
bl_idname = "object.dumpmesh"
bl_label = "DumpMesh"
bl_options = {'REGISTER','UNDO'}
include_operator : BoolProperty(name="Add operator",
description="Add operator definition",
default=True)
compact : BoolProperty(name="Compact",
description="Omit newlines and other whitespace",
default=True)
geomonly : BoolProperty(name="Geometry only",
description="Omit everything other than verts, edges and faces",
default=False)
digits : IntProperty(name="Digits",
description="Number of decimal places in vertex coordinates",
default=4,
min=1, max=9)
def format_vertex(self, v):
return ("({co[0]:.%dg},{co[1]:.%dg},{co[2]:.%dg})"%(self.digits,self.digits,self.digits)).format(co=v)
def tuple_or_orig(self, v):
if type(v) == str :
return v
elif type(v) == bmesh.types.BMLoopUV:
return tuple(v.uv)
# elif type(v) == bmesh.types.BMTexPoly: # this types is not yet defined
# return None # has .image attribute but not sure what it is for
# skin and deform values also lack an entry in bmesh.types, we ignore anything else
elif v.__class__.__name__.startswith("BMVertSkin"):
return tuple(v.radius)
elif v.__class__.__name__.startswith("BM"):
return None
elif hasattr(v, '__iter__') or hasattr(v, '__len__'):
return tuple(v)
return v
@classmethod
def poll(cls, context):
return (( context.active_object is not None )
and (type(context.active_object.data) == bpy.types.Mesh))
def execute(self, context):
output = bpy.data.texts.new("mesh_data.py")
if self.include_operator:
output.write(b64decode(GPLblurb).decode() + '\n')
output.write(b64decode(BaseClass).decode() + '\n')
names = []
for ob in context.selected_objects:
me = ob.data
bm = bmesh.new()
bm.from_mesh(me)
name = ob.name.replace(".","_").replace(" ","_")
names.append(name)
bm.verts.ensure_lookup_table()
bm.edges.ensure_lookup_table()
bm.faces.ensure_lookup_table()
nl = "" if self.compact else "\n"
tb = "" if self.compact else "\t"
output.write("class " + name + "(DumpMesh):\n" + nl)
output.write("\tverts = [" + nl)
for v in bm.verts:
output.write(tb + tb + self.format_vertex(v.co) + "," + nl)
output.write(tb + "]\n\n")
output.write("\tedges = [" + nl)
for e in bm.edges:
output.write(tb + tb + str(tuple(v.index for v in e.verts)) + "," + nl)
output.write(tb + "]\n\n")
output.write("\tfaces = [" + nl)
for f in bm.faces:
output.write(tb + tb + str(tuple(v.index for v in f.verts)) + "," + nl)
output.write(tb + "]\n\n")
if not self.geomonly:
for etype in ('verts', 'edges', 'faces'):
output.write("\t%s_layers = {"%etype + nl)
seq = getattr(bm, etype)
for attr in dir(seq.layers):
attrval = getattr(seq.layers,attr)
if type(attrval) == bmesh.types.BMLayerCollection:
output.write(tb + tb + "'"+attr+"': {" + nl)
for key, val in attrval.items():
output.write(tb + tb + tb + "'" + key + "': {" + nl)
for v in seq:
output.write(tb + tb + tb + str(v.index) + ":" + str(self.tuple_or_orig(v[val])) + "," + nl)
output.write(tb + tb + tb + "}, " + nl)
output.write(tb + tb + "}, " + nl)
output.write("\t}\n\n")
output.write("\tloops_layers = {" + nl)
for attr in dir(bm.loops.layers):
attrval = getattr(bm.loops.layers,attr)
if type(attrval) == bmesh.types.BMLayerCollection:
output.write(tb + tb + "'"+attr+"': {" + nl)
for key, val in attrval.items():
output.write(tb + tb + tb + "'" + key + "': {" + nl)
for f in bm.faces:
output.write(tb + tb + tb + tb + str(f.index) + ": {" + nl)
for l in f.loops:
output.write(tb + tb + tb + tb + tb + str(l.index) + ":" + str(self.tuple_or_orig(l[val])) + "," + nl)
output.write(tb + tb + tb + tb + "}," + nl)
output.write(tb + tb + tb + "}," + nl)
output.write(tb + tb + "}," + nl)
output.write("\t}\n\n")
output.write("\tvert_attributes = {\n")
for attr in ('normal', 'select' ):
el = [self.tuple_or_orig(getattr(v,attr)) for v in bm.verts]
output.write("\t" + tb + "'" + attr + "' : " + str(el) + ",\n")
output.write("\t}\n\n")
output.write("\tedge_attributes = {\n")
for attr in ('seam', 'smooth', 'select'):
el = [self.tuple_or_orig(getattr(e,attr)) for e in bm.edges]
output.write("\t" + tb + "'" + attr + "' : " + str(el) + ",\n")
output.write("\t}\n\n")
output.write("\tface_attributes = {\n")
for attr in ('normal', 'smooth', 'select'):
el = [self.tuple_or_orig(getattr(f,attr)) for f in bm.faces]
output.write("\t" + tb + "'" + attr + "' : " + str(el) + ",\n")
output.write("\t}\n\n")
output.write("\n")
bm.free()
if self.include_operator:
output.write('meshes = [ ' + ', '.join(names) + ' ]\n\n')
output.write(b64decode(OperatorDef).decode())
# force newly created text block on top if text editor is visible
for a in context.screen.areas:
for s in a.spaces:
if s.type == 'TEXT_EDITOR':
s.text = output
return {'FINISHED'}
def register():
bpy.utils.register_class(DumpMesh)
bpy.types.VIEW3D_MT_object.append(menu_func)
def unregister():
bpy.utils.unregister_class(DumpMesh)
bpy.types.VIEW3D_MT_object.remove(menu_func)
def menu_func(self, context):
self.layout.operator(DumpMesh.bl_idname, icon='PLUGIN')