blendercam/scripts/addons/fabex/ui/panels/op_properties_panel.py

280 wiersze
11 KiB
Python

2024-10-22 20:19:27 +00:00
"""CMC CAM 'op_properties.py'
'CAM Operation Setup' panel in Properties > Render
"""
import bpy
from bpy.types import Panel
from .parent_panel import CAMParentPanel
2024-10-22 20:19:27 +00:00
class CAM_OPERATION_PROPERTIES_Panel(CAMParentPanel, Panel):
2024-10-22 20:19:27 +00:00
"""CAM Operation Properties Panel"""
2024-10-22 21:13:36 +00:00
2024-10-29 20:58:51 +00:00
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "CNC"
2024-11-06 10:48:27 +00:00
bl_label = "[ Operation Setup ]"
2024-12-18 20:37:25 +00:00
bl_idname = "FABEX_PT_CAM_OPERATION"
2024-10-24 13:36:37 +00:00
panel_interface_level = 0
2024-10-22 20:19:27 +00:00
def __init__(self, *args, **kwargs):
Panel.__init__(self, *args, **kwargs)
CAMParentPanel.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)
2024-10-26 01:17:12 +00:00
def draw_overshoot(self, col):
2024-10-23 21:37:33 +00:00
# Overshoot
2024-11-05 16:14:13 +00:00
row = col.row()
row.use_property_split = False
row.prop(self.op, "straight", text="Overshoot")
2024-10-22 20:19:27 +00:00
2024-10-23 21:37:33 +00:00
def draw(self, context):
layout = self.layout
2024-10-26 01:17:12 +00:00
layout.use_property_split = True
layout.use_property_decorate = False
col = layout.column(align=True)
2024-10-29 20:58:51 +00:00
col.scale_y = 1.2
2024-11-05 16:14:13 +00:00
# Machine Axis Count
2024-10-24 13:36:37 +00:00
if self.level >= 2:
2024-11-05 16:14:13 +00:00
col.prop(self.op, "machine_axes", text="Axis Count")
2024-10-24 13:36:37 +00:00
# Strategy
if self.op.machine_axes == "4":
col.prop(self.op, "strategy_4_axis")
if self.op.strategy_4_axis == "INDEXED":
2024-10-26 01:17:12 +00:00
col.prop(self.op, "strategy")
col.prop(self.op, "rotary_axis_1")
2024-10-24 13:36:37 +00:00
elif self.op.machine_axes == "5":
col.prop(self.op, "strategy_5_axis")
if self.op.strategy_5_axis == "INDEXED":
2024-10-26 01:17:12 +00:00
col.prop(self.op, "strategy")
col.prop(self.op, "rotary_axis_1")
col.prop(self.op, "rotary_axis_2")
2024-10-24 13:36:37 +00:00
else:
2024-10-26 01:17:12 +00:00
col.prop(self.op, "strategy")
2024-10-24 13:36:37 +00:00
2024-11-05 16:14:13 +00:00
# Individual Strategy Settings
box = layout.box()
box.label(text=self.op.strategy.title(), icon="SETTINGS")
2024-10-27 17:54:48 +00:00
2024-10-24 13:36:37 +00:00
# Cutout Options
if self.op.strategy in ["CUTOUT"]:
2024-10-26 01:17:12 +00:00
col = box.column(align=True)
2024-10-24 13:36:37 +00:00
# Cutout Type
2024-10-26 01:17:12 +00:00
col.prop(self.op, "cut_type")
2024-10-24 13:36:37 +00:00
# Startpoint
2024-10-26 01:17:12 +00:00
col.prop(self.op, "profile_start")
2024-11-05 16:14:13 +00:00
# Skin
col.prop(self.op, "skin")
if self.op.cut_type in ["OUTSIDE", "INSIDE"]:
self.draw_overshoot(col=col)
2024-10-24 13:36:37 +00:00
# Lead In & Out
2024-11-05 16:14:13 +00:00
box = col.box()
sub = box.column(align=True)
sub.label(text="Radius")
sub.prop(self.op, "lead_in", text="Lead-in")
sub.prop(self.op, "lead_out", text="Lead-out")
2024-10-24 13:36:37 +00:00
if self.op.strategy in ["CUTOUT", "CURVE"]:
2024-10-27 17:54:48 +00:00
if self.op.strategy == "CURVE":
col = box.column(align=True)
2024-11-05 16:14:13 +00:00
# Outlines Box
box = col.box()
subcol = box.column(align=True)
subcol.label(text="Outlines")
2024-10-24 13:36:37 +00:00
# Outlines
2024-11-05 16:14:13 +00:00
subcol.prop(self.op, "outlines_count", text="Count")
2024-10-24 13:36:37 +00:00
# Merge
2024-11-05 16:14:13 +00:00
row = subcol.row()
row.use_property_split = False
row.prop(self.op, "dont_merge", text="Don't Merge")
if self.op.outlines_count > 1:
subcol.prop(self.op.movement, "insideout")
box = subcol.box()
sub = box.column(align=True)
2025-01-27 16:01:10 +00:00
sub.label(text="Toolpath")
sub.prop(self.op, "distance_between_paths", text="Stepover")
2024-10-24 13:36:37 +00:00
# Waterline Options
if self.op.strategy in ["WATERLINE"]:
2024-10-26 01:17:12 +00:00
col = box.column(align=True)
2024-11-05 16:14:13 +00:00
if self.op.optimisation.use_opencamlib:
box = col.box()
box.alert = True
box.label(text="Ocl Doesn't Support Fill Areas", icon="ERROR")
else:
col.prop(self.op, "slice_detail", text="Slice Detail")
col.prop(self.op, "skin")
if self.op.skin == 0:
box = col.box()
box.alert = True
box.label(text="Waterline Needs a Skin Margin", icon="ERROR")
row = col.row()
row.use_property_split = False
row.prop(self.op, "waterline_project")
row = col.row()
row.use_property_split = False
row.prop(self.op, "waterline_fill", text="Fill Between Slices")
2024-10-24 13:36:37 +00:00
if self.op.waterline_fill:
2024-11-05 16:14:13 +00:00
box = col.box()
sub = box.column(align=True)
2025-01-27 16:01:10 +00:00
sub.label(text="Toolpath")
sub.prop(self.op, "distance_between_paths", text="Stepover")
2024-10-24 13:36:37 +00:00
# Carve Options
if self.op.strategy in ["CARVE"]:
2024-10-26 01:17:12 +00:00
col = box.column(align=True)
2024-11-05 16:14:13 +00:00
col.prop(self.op, "carve_depth", text="Depth")
col.prop(self.op, "skin")
2024-11-05 16:14:13 +00:00
box = col.box()
sub = box.column(align=True)
2025-01-27 16:01:10 +00:00
sub.label(text="Toolpath")
sub.prop(self.op, "distance_along_paths", text="Detail")
2024-10-24 13:36:37 +00:00
# Medial Axis Options
if self.op.strategy in ["MEDIAL_AXIS"]:
2024-10-26 01:17:12 +00:00
col = box.column(align=True)
2024-11-05 16:14:13 +00:00
col.prop(self.op, "medial_axis_threshold", text="Threshold")
col.prop(self.op, "medial_axis_subdivision", text="Detail Size")
row = col.row()
row.use_property_split = False
row.prop(self.op, "add_pocket_for_medial", text="Add Pocket")
row = col.row()
row.use_property_split = False
row.prop(self.op, "add_mesh_for_medial", text="Add Medial Mesh")
2024-10-24 13:36:37 +00:00
# Drill Options
if self.op.strategy in ["DRILL"]:
2024-10-26 01:17:12 +00:00
col = box.column(align=True)
col.prop(self.op, "drill_type")
2024-11-05 16:14:13 +00:00
# self.draw_enable_A_B_axis(col=col)
2024-10-24 13:36:37 +00:00
# Pocket Options
if self.op.strategy in ["POCKET"]:
2024-10-26 01:17:12 +00:00
col = box.column(align=True)
if self.op.pocket_type == "PARALLEL":
2024-11-05 16:14:13 +00:00
warnbox = col.box()
warnbox.alert = True
warnbox.label(text="! Warning ! Experimental !", icon="ERROR")
col.prop(self.op, "pocket_type", text="Type")
if self.op.pocket_type == "PARALLEL":
col.prop(self.op, "parallel_pocket_angle", text="Angle")
col.prop(self.op, "skin")
2024-11-05 16:14:13 +00:00
subcol = col.column(align=True)
subcol.use_property_split = False
subcol.prop(self.op, "parallel_pocket_crosshatch", text="Crosshatch")
subcol.prop(self.op, "parallel_pocket_contour")
2024-11-05 16:14:13 +00:00
2024-10-24 13:36:37 +00:00
else:
2024-10-26 01:17:12 +00:00
col.prop(self.op, "pocket_option")
col.prop(self.op, "skin")
2024-11-05 16:14:13 +00:00
self.draw_overshoot(col=col)
row = col.row()
row.use_property_split = False
row.prop(self.op, "pocket_to_curve")
2024-11-05 16:14:13 +00:00
box = col.box()
sub = box.column(align=True)
2025-01-27 16:01:10 +00:00
sub.label(text="Toolpath")
sub.prop(self.op, "distance_between_paths", text="Stepover")
2024-10-24 13:36:37 +00:00
# Default Options
if self.op.strategy not in [
"CUTOUT",
"CURVE",
"WATERLINE",
"CARVE",
"MEDIAL_AXIS",
"DRILL",
"POCKET",
]:
2024-11-05 16:14:13 +00:00
# box = layout.box()
2024-10-26 01:17:12 +00:00
col = box.column(align=True)
2024-11-05 16:14:13 +00:00
row = col.row()
row.use_property_split = False
row.prop(self.op, "inverse")
2024-10-24 13:36:37 +00:00
if self.op.strategy in ["PARALLEL", "CROSS"]:
col.prop(self.op, "skin")
2024-10-26 01:17:12 +00:00
col.prop(self.op, "parallel_angle")
2024-11-05 16:14:13 +00:00
box = col.box()
col = box.column(align=True)
2025-01-27 16:01:10 +00:00
col.label(text="Toolpath")
col.prop(self.op, "distance_between_paths", text="Stepover")
col.prop(self.op, "distance_along_paths", text="Detail")
2024-10-27 17:54:48 +00:00
2024-11-05 16:14:13 +00:00
# A & B, Array, Bridges Options
2024-10-24 13:36:37 +00:00
if self.level >= 1:
2024-11-05 16:14:13 +00:00
# A & B Axes
if self.op.strategy in [
"CUTOUT",
"CURVE",
"DRILL",
"PROFILE",
"POCKET",
"PARALLEL",
"CROSS",
]:
layout.use_property_split = False
header, panel = layout.panel("ab_axes", default_closed=True)
header.label(text="A & B Axes")
2024-10-26 01:17:12 +00:00
if panel:
2024-11-05 16:14:13 +00:00
subheader, subpanel = panel.panel("a_axis", default_closed=True)
subheader.prop(self.op, "enable_a_axis", text="A Axis")
2024-11-05 16:14:13 +00:00
if subpanel:
subpanel.enabled = self.op.enable_a_axis
2024-11-05 16:14:13 +00:00
col = subpanel.column(align=True)
row = col.row()
row.use_property_split = True
row.prop(self.op, "rotation_a")
col.prop(self.op, "a_along_x")
if self.op.a_along_x:
2024-11-05 16:14:13 +00:00
col.label(text="Ⓐ || Ⓧ - Ⓑ || Ⓨ")
else:
col.label(text="Ⓐ || Ⓨ - Ⓑ || Ⓧ")
subheader, subpanel = panel.panel("b_axis", default_closed=True)
subheader.prop(self.op, "enable_b_axis", text="B Axis")
2024-11-05 16:14:13 +00:00
if subpanel:
subpanel.enabled = self.op.enable_b_axis
2024-11-05 16:14:13 +00:00
col = subpanel.column(align=True)
col.use_property_split = True
col.prop(self.op, "rotation_b")
2024-10-24 13:36:37 +00:00
# Array
if self.op.machine_axes == "3":
2024-11-05 16:14:13 +00:00
layout.use_property_split = False
header, panel = layout.panel("use_array", default_closed=True)
header.prop(self.op, "array", text="Array")
2024-10-26 01:17:12 +00:00
if panel:
2024-11-05 16:14:13 +00:00
panel.enabled = self.op.array
panel.use_property_split = True
2024-10-26 01:17:12 +00:00
col = panel.column(align=True)
col.prop(self.op, "array_x_count")
col.prop(self.op, "array_x_distance")
col.prop(self.op, "array_y_count")
col.prop(self.op, "array_y_distance")
2024-11-05 16:14:13 +00:00
# Bridges
if self.op.strategy not in ["POCKET", "DRILL", "CURVE", "MEDIAL_AXIS"]:
layout.use_property_split = False
header, panel = layout.panel("bridges", default_closed=True)
header.prop(self.op, "use_bridges", text="Bridges (Tabs)")
if panel:
panel.enabled = self.op.use_bridges
col = panel.column(align=True)
col.use_property_split = True
col.prop(self.op, "bridges_width", text="Width")
col.prop(self.op, "bridges_height", text="Height")
col.prop_search(
self.op,
"bridges_collection_name",
bpy.data,
"collections",
text="Collection",
)
col.prop(self.op, "use_bridge_modifiers", text="Use Modifiers")
col.operator("scene.cam_bridges_add", text="Autogenerate")