Print3D: Cleanup

This commit is contained in:
Mikhail Rachinskiy 2018-06-15 18:20:00 +04:00
parent 9ae033c49c
commit 3959f1016e
4 changed files with 21 additions and 20 deletions

View File

@ -24,11 +24,11 @@ bl_info = {
"blender": (2, 79, 0),
"location": "3D View > Toolbox",
"description": "Utilities for 3D printing",
"warning": "",
"wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
"Scripts/Modeling/PrintToolbox",
"support": 'OFFICIAL',
"category": "Mesh"}
"category": "Mesh",
}
if "bpy" in locals():
@ -153,10 +153,7 @@ class Print3D_Preferences(AddonPreferences):
def draw(self, context):
layout = self.layout
col = layout.column()
col.label(text="Tab Category:")
col.prop(self, "category", text="")
layout.prop(self, "category")
classes = (

View File

@ -20,14 +20,16 @@
# Export wrappers and integration with external tools.
import bpy
import os
import bpy
def image_copy_guess(filepath, objects):
# 'filepath' is the path we are writing to.
import shutil
from bpy_extras import object_utils
image = None
for obj in objects:
image = object_utils.object_image_guess(obj)
@ -168,7 +170,7 @@ def write_mesh(context, info, report_cb):
global_scale=global_scale,
)
else:
assert(0)
assert 0
# for formats that don't support images
if export_format in {'STL', 'PLY'}:

View File

@ -21,7 +21,6 @@
# Generic helper functions, to be used by any modules.
import bmesh
import array
def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifiers=False):
@ -29,7 +28,7 @@ def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifier
Returns a transformed, triangulated copy of the mesh
"""
assert(obj.type == 'MESH')
assert obj.type == 'MESH'
if apply_modifiers and obj.modifiers:
import bpy
@ -101,18 +100,17 @@ def bmesh_check_self_intersect_object(obj):
returns an array of edge index values.
"""
import bpy
import array
import mathutils
if not obj.data.polygons:
return array.array('i', ())
bm = bmesh_copy_from_object(obj, transform=False, triangulate=False)
import mathutils
tree = mathutils.bvhtree.BVHTree.FromBMesh(bm, epsilon=0.00001)
overlap = tree.overlap(tree)
faces_error = {i for i_pair in overlap for i in i_pair}
return array.array('i', faces_error)
@ -142,7 +140,7 @@ def bmesh_face_points_random(f, num_points=1, margin=0.05):
def bmesh_check_thick_object(obj, thickness):
import array
import bpy
# Triangulate
@ -284,7 +282,7 @@ def object_merge(context, objects):
def face_is_distorted(ele, angle_distort):
no = ele.normal
angle_fn = no.angle
for loop in ele.loops:
loopno = loop.calc_normal()
@ -293,5 +291,5 @@ def face_is_distorted(ele, angle_distort):
if angle_fn(loopno, 1000.0) > angle_distort:
return True
return False

View File

@ -20,8 +20,6 @@
# All Operator
import array
import bpy
from bpy.types import Operator
from bpy.props import (
@ -131,6 +129,8 @@ class MESH_OT_Print3D_Check_Solid(Operator):
@staticmethod
def main_check(obj, info):
import array
bm = mesh_helpers.bmesh_copy_from_object(obj, transform=False, triangulate=False)
edges_non_manifold = array.array('i', (i for i, ele in enumerate(bm.edges)
@ -173,6 +173,8 @@ class MESH_OT_Print3D_Check_Degenerate(Operator):
@staticmethod
def main_check(obj, info):
import array
scene = bpy.context.scene
print_3d = scene.print_3d
threshold = print_3d.threshold_zero
@ -201,6 +203,8 @@ class MESH_OT_Print3D_Check_Distorted(Operator):
@staticmethod
def main_check(obj, info):
import array
scene = bpy.context.scene
print_3d = scene.print_3d
angle_distort = print_3d.angle_distort
@ -356,7 +360,7 @@ class MESH_OT_Print3D_Clean_Isolated(Operator):
return ele.is_wire
def vert_is_isolated(ele):
return (not bool(ele.link_edges))
return not bool(ele.link_edges)
# --- face
elems_remove = [ele for ele in bm.faces if face_is_isolated(ele)]