From 2dff4b601d79b0f7231ef9aaf569f494f975da08 Mon Sep 17 00:00:00 2001 From: migo101 Date: Sun, 30 Jul 2023 17:21:48 +0200 Subject: [PATCH] Change min depth params --- scripts/addons/cam/__init__.py | 30 ++++++++++++++++++---------- scripts/addons/cam/ops.py | 6 ++---- scripts/addons/cam/strategy.py | 4 ++-- scripts/addons/cam/ui_panels/area.py | 12 +++++------ scripts/addons/cam/utils.py | 2 +- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/scripts/addons/cam/__init__.py b/scripts/addons/cam/__init__.py index f8ea34de..2cf517dc 100644 --- a/scripts/addons/cam/__init__.py +++ b/scripts/addons/cam/__init__.py @@ -716,14 +716,22 @@ class camOperation(bpy.types.PropertyGroup): # helix_angle: bpy.props.FloatProperty(name="Helix ramp angle", default=3*math.pi/180, min=0.00001, max=math.pi*0.4999,precision=1, subtype="ANGLE" , unit="ROTATION" , update = updateRest) - minz_from_ob: bpy.props.BoolProperty(name="Depth from object", description="Operation ending depth from object", - default=True, update=updateRest) - minz_from_material: bpy.props.BoolProperty(name="Depth from material", - description="Operation ending depth from material", - default=False, update=updateRest) - minz: bpy.props.FloatProperty(name="Operation depth end", default=-0.01, min=-3, max=3, precision=cam.constants.PRECISION, - unit="LENGTH", - update=updateRest) # this is input minz. True minimum z can be something else, depending on material e.t.c. + minz: bpy.props.FloatProperty(name="Operation depth end", + default=-0.01, min=-3, max=3, precision=cam.constants.PRECISION, + unit="LENGTH", + update=updateRest) + + minz_from: bpy.props.EnumProperty(name='Set max depth from', + description = 'Set maximum operation depth', + items=( + ('OBJECT', 'Object', 'Set max operation depth from Object'), + ('MATERIAL', 'Material', 'Set max operation depth from Material'), + ('CUSTOM', 'Custom', 'Custom max depth'), + ), + default='OBJECT', + update=updateRest + ) + start_type: bpy.props.EnumProperty(name='Start type', items=( ('ZLEVEL', 'Z level', 'Starts on a given Z level'), @@ -1004,7 +1012,6 @@ def check_operations_on_load(context): if o.computing: o.computing = False - class CAM_CUTTER_MT_presets(Menu): bl_label = "Cutter presets" preset_subdir = "cam_cutters" @@ -1060,7 +1067,7 @@ class AddPresetCamOperation(bl_operators.presets.AddPresetBase, Operator): preset_values = ['o.use_layers', 'o.info.duration', 'o.info.chipload', 'o.material.estimate_from_model', 'o.movement.stay_low', 'o.carve_depth', 'o.dist_along_paths', 'o.source_image_crop_end_x', 'o.source_image_crop_end_y', 'o.material.size', 'o.material.radius_around_model', 'o.use_limit_curve', 'o.cut_type', 'o.optimisation.use_exact', - 'o.optimisation.exact_subdivide_edges', 'o.minz_from_ob', 'o.movement.free_height', + 'o.optimisation.exact_subdivide_edges', 'o.minz_from', 'o.movement.free_height', 'o.source_image_crop_start_x', 'o.movement.insideout', 'o.movement.movement.spindle_rotation', 'o.skin', 'o.source_image_crop_start_y', 'o.movement.type', 'o.source_image_crop', 'o.limit_curve', 'o.spindle_rpm', 'o.ambient_behaviour', 'o.cutter_type', 'o.source_image_scale_z', @@ -1074,7 +1081,7 @@ class AddPresetCamOperation(bl_operators.presets.AddPresetBase, Operator): 'o.optimize_threshold', 'o.movement.protect_vertical', 'o.plunge_feedrate', 'o.minz', 'o.info.warnings', 'o.object_name', 'o.optimize', 'o.parallel_angle', 'o.cutter_length', 'o.output_header', 'o.gcode_header', 'o.output_trailer', 'o.gcode_trailer', 'o.use_modifiers', - 'o.minz_from_material', 'o.movement.useG64', + 'o.movement.useG64', 'o.movement.G64', 'o.enable_A', 'o.enable_B', 'o.A_along_x', 'o.rotation_A', 'o.rotation_B', 'o.straight'] preset_subdir = "cam_operations" @@ -1458,6 +1465,7 @@ def register(): bpy.types.Scene.interface = bpy.props.PointerProperty(type=CAM_INTERFACE_Properties) + def unregister(): for p in classes: bpy.utils.unregister_class(p) diff --git a/scripts/addons/cam/ops.py b/scripts/addons/cam/ops.py index ac3d61db..2a07bc16 100644 --- a/scripts/addons/cam/ops.py +++ b/scripts/addons/cam/ops.py @@ -553,9 +553,7 @@ def Add_Pocket(self, maxdepth, sname, new_cutter_diameter): o.use_layers = False o.material.estimate_from_model = False o.material.size[2] = -maxdepth - o.minz_from_ob = False - o.minz_from_material = True - + o.minz_from = 'MATERIAL' class CamOperationAdd(bpy.types.Operator): """Add new CAM operation""" @@ -581,7 +579,7 @@ class CamOperationAdd(bpy.types.Operator): o.minz = minz s.cam_active_operation = len(s.cam_operations) - 1 - + o.name = f"Op_{ob.name}_{s.cam_active_operation + 1}" o.filename = o.name diff --git a/scripts/addons/cam/strategy.py b/scripts/addons/cam/strategy.py index 5612eb59..887da6a0 100644 --- a/scripts/addons/cam/strategy.py +++ b/scripts/addons/cam/strategy.py @@ -550,7 +550,7 @@ def drill(o): for layer in layers: for chunk in chunks: # If using object for minz then use z from points in object - if o.minz_from_ob: + if o.minz_from == 'OBJECT': z = chunk.points[0][2] else: # using operation minz z = o.minz @@ -925,7 +925,7 @@ def chunksToMesh(chunks, o): def checkminz(o): - if o.minz_from_material: + if o.minz_from == 'MATERIAL': return o.min.z else: return o.minz diff --git a/scripts/addons/cam/ui_panels/area.py b/scripts/addons/cam/ui_panels/area.py index 74de4af5..d7386e36 100644 --- a/scripts/addons/cam/ui_panels/area.py +++ b/scripts/addons/cam/ui_panels/area.py @@ -36,12 +36,12 @@ class CAM_AREA_Panel(CAMButtonsPanel, bpy.types.Panel): if self.op.strategy == 'CURVE': self.layout.label(text="cannot use depth from object using CURVES") - if not self.op.minz_from_ob: - if not self.op.minz_from_material: - self.layout.prop(self.op, 'minz') - self.layout.prop(self.op, 'minz_from_material') - if not self.op.minz_from_material: - self.layout.prop(self.op, 'minz_from_ob') + row = self.layout.row(align=True) + row.label(text='Set max depth from') + row.prop(self.op, 'minz_from', text='') + if self.op.minz_from == 'CUSTOM': + self.layout.prop(self.op, 'minz') + else: self.layout.prop(self.op, 'source_image_scale_z') self.layout.prop(self.op, 'source_image_size_x') diff --git a/scripts/addons/cam/utils.py b/scripts/addons/cam/utils.py index c1ee3e2e..c7e17fa8 100644 --- a/scripts/addons/cam/utils.py +++ b/scripts/addons/cam/utils.py @@ -286,7 +286,7 @@ def getBounds(o): print("valid geometry") minx, miny, minz, maxx, maxy, maxz = getBoundsWorldspace(o.objects, o.use_modifiers) - if o.minz_from_ob: + if o.minz_from == 'OBJECT': if minz == 10000000: minz = 0 print("minz from object:" + str(minz))