3D Print Toolbox: Add hollow out #105194
@ -833,12 +833,12 @@ class MESH_OT_print3d_hollow(Operator):
|
||||
|
||||
offset_direction: EnumProperty(
|
||||
items=[
|
||||
('inside', "Inside", "Offset surface inside of object"),
|
||||
('outside', "Outside", "Offset surface outside of object"),
|
||||
('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',
|
||||
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
|
||||
@ -861,6 +861,18 @@ class MESH_OT_print3d_hollow(Operator):
|
||||
description="Create hollowed out copy of the object",
|
||||
)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
layout.use_property_decorate = False
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.prop(self, "offset_direction", expand=True)
|
||||
layout.prop(self, "offset")
|
||||
layout.prop(self, "voxel_size")
|
||||
layout.prop(self, "make_hollow_duplicate")
|
||||
|
||||
def execute(self, context):
|
||||
import numpy as np
|
||||
import pyopenvdb as vdb
|
||||
@ -883,9 +895,9 @@ class MESH_OT_print3d_hollow(Operator):
|
||||
ntris = len(mesh_target.loop_triangles)
|
||||
verts = np.zeros(3 * nverts, dtype=np.float32)
|
||||
tris = np.zeros(3 * ntris, dtype=np.int32)
|
||||
mesh_target.vertices.foreach_get('co', verts)
|
||||
mesh_target.vertices.foreach_get("co", verts)
|
||||
verts.shape = (-1, 3)
|
||||
mesh_target.loop_triangles.foreach_get('vertices', tris)
|
||||
mesh_target.loop_triangles.foreach_get("vertices", tris)
|
||||
tris.shape = (-1, 3)
|
||||
|
||||
# Generate VDB levelset
|
||||
@ -895,7 +907,7 @@ class MESH_OT_print3d_hollow(Operator):
|
||||
levelset = vdb.FloatGrid.createLevelSetFromPolygons(verts, triangles=tris, transform=trans, halfWidth=half_width)
|
||||
|
||||
# Generate offset surface
|
||||
if self.offset_direction == 'inside':
|
||||
if self.offset_direction == 'INSIDE':
|
||||
newverts, newquads = levelset.convertToQuads(-self.offset)
|
||||
else:
|
||||
newverts, newquads = levelset.convertToQuads(self.offset)
|
||||
@ -905,12 +917,12 @@ class MESH_OT_print3d_hollow(Operator):
|
||||
# Instantiate new object in Blender
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
mesh_offset = bpy.data.meshes.new(mesh_target.name + ' offset')
|
||||
mesh_offset = bpy.data.meshes.new(mesh_target.name + " offset")
|
||||
mesh_offset.from_pydata(newverts, [], polys)
|
||||
|
||||
# For some reason OpenVDB has inverted normals
|
||||
mesh_offset.flip_normals()
|
||||
obj_offset = bpy.data.objects.new(obj.name + ' offset', mesh_offset)
|
||||
obj_offset = bpy.data.objects.new(obj.name + " offset", mesh_offset)
|
||||
obj_offset.matrix_world.translation = obj.matrix_world.translation
|
||||
bpy.context.collection.objects.link(obj_offset)
|
||||
obj_offset.select_set(True)
|
||||
@ -921,7 +933,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.offset_direction == 'inside':
|
||||
if self.offset_direction == 'INSIDE':
|
||||
mesh_offset.flip_normals()
|
||||
else:
|
||||
mesh_target.flip_normals()
|
||||
|
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.