3D Print Toolbox: Add hollow out #105194
@ -129,23 +129,6 @@ class SceneProperties(PropertyGroup):
|
||||
min=0.0,
|
||||
step=1,
|
||||
)
|
||||
hollow_voxel_size: FloatProperty(
|
||||
name="Voxel size",
|
||||
description="Size of the voxel used for volume evaluation. Lower values preserve finer details",
|
||||
default=1.0,
|
||||
min=0.0001,
|
||||
step=1,
|
||||
subtype='DISTANCE',
|
||||
)
|
||||
make_hollow_duplicate: BoolProperty(
|
||||
name="Hollow Duplicate",
|
||||
description="Create hollowed out copy of the object",
|
||||
)
|
||||
make_hollow_inside: BoolProperty(
|
||||
name="Inside",
|
||||
description="Offset surface inside of the object",
|
||||
default=True,
|
||||
)
|
||||
|
||||
|
||||
classes = (
|
||||
|
@ -13,6 +13,7 @@ from bpy.props import (
|
||||
IntProperty,
|
||||
FloatProperty,
|
||||
BoolProperty,
|
||||
EnumProperty,
|
||||
)
|
||||
import bmesh
|
||||
|
||||
@ -828,8 +829,17 @@ class MESH_OT_print3d_hollow(Operator):
|
||||
bl_idname = "mesh.print3d_hollow"
|
||||
bl_label = "Hollow"
|
||||
bl_description = "Create offset surface"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
|
||||
|
||||
offset_direction: EnumProperty(
|
||||
items=[
|
||||
('inside', "Inside", "Offset surface inside of object"),
|
||||
('outside', "Outside", "Offset surface outside of object"),
|
||||
],
|
||||
name="Offset Direction",
|
||||
description="Where the offset surface is created relative to the object",
|
||||
default='inside',
|
||||
)
|
||||
MikhailRachinskiy marked this conversation as resolved
|
||||
offset: FloatProperty(
|
||||
name="Offset",
|
||||
MikhailRachinskiy marked this conversation as resolved
Mikhail Rachinskiy
commented
default=1 default=1
|
||||
description="Surface offset in relation to original mesh",
|
||||
@ -841,7 +851,7 @@ class MESH_OT_print3d_hollow(Operator):
|
||||
voxel_size: FloatProperty(
|
||||
name="Voxel size",
|
||||
description="Size of the voxel used for volume evaluation. Lower values preserve finer details",
|
||||
default=5.0,
|
||||
default=1.0,
|
||||
min=0.0001,
|
||||
step=1,
|
||||
subtype='DISTANCE',
|
||||
@ -850,11 +860,6 @@ class MESH_OT_print3d_hollow(Operator):
|
||||
name="Hollow Duplicate",
|
||||
description="Create hollowed out copy of the object",
|
||||
)
|
||||
make_hollow_inside: BoolProperty(
|
||||
name="Inside",
|
||||
description="Offset surface inside of the object",
|
||||
default=True,
|
||||
)
|
||||
|
||||
def execute(self, context):
|
||||
import numpy as np
|
||||
@ -890,7 +895,7 @@ class MESH_OT_print3d_hollow(Operator):
|
||||
levelset = vdb.FloatGrid.createLevelSetFromPolygons(verts, triangles=tris, transform=trans, halfWidth=half_width)
|
||||
|
||||
# Generate offset surface
|
||||
if self.make_hollow_inside:
|
||||
if self.offset_direction == 'inside':
|
||||
newverts, newquads = levelset.convertToQuads(-self.offset)
|
||||
else:
|
||||
newverts, newquads = levelset.convertToQuads(self.offset)
|
||||
@ -916,7 +921,7 @@ class MESH_OT_print3d_hollow(Operator):
|
||||
bpy.context.collection.objects.link(obj_hollow)
|
||||
obj_hollow.matrix_world.translation = obj.matrix_world.translation
|
||||
obj_hollow.select_set(True)
|
||||
if self.make_hollow_inside:
|
||||
if self.offset_direction == 'inside':
|
||||
mesh_offset.flip_normals()
|
||||
else:
|
||||
mesh_target.flip_normals()
|
||||
@ -925,23 +930,10 @@ class MESH_OT_print3d_hollow(Operator):
|
||||
else:
|
||||
bpy.data.meshes.remove(mesh_target)
|
||||
|
||||
print_3d = context.scene.print_3d
|
||||
print_3d.hollow_offset = self.offset
|
||||
print_3d.hollow_voxel_size = self.voxel_size
|
||||
print_3d.make_hollow_duplicate = self.make_hollow_duplicate
|
||||
print_3d.make_hollow_inside = self.make_hollow_inside
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
print_3d = context.scene.print_3d
|
||||
self.offset = print_3d.hollow_offset
|
||||
self.voxel_size = print_3d.hollow_voxel_size
|
||||
self.make_hollow_duplicate = print_3d.make_hollow_duplicate
|
||||
self.make_hollow_inside = print_3d.make_hollow_inside
|
||||
if context.mode == 'EDIT_MESH':
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
wm = context.window_manager
|
||||
return wm.invoke_props_dialog(self)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user
Enum values are supposed to be in
UPPERCASE
I noticed inconsistent use of double vs single quotation marks, Blender code guidelines recommends: single quotes when using enum values, double quotes everything else.
Sorry, my bad. It should be fixed now.