2024-04-15 14:02:58 +00:00
|
|
|
"""BlenderCAM 'machine.py'
|
|
|
|
|
|
|
|
|
|
'CAM Machine' panel in Properties > Render
|
|
|
|
|
"""
|
|
|
|
|
|
2022-04-12 09:35:49 +00:00
|
|
|
import bpy
|
2024-04-02 15:07:14 +00:00
|
|
|
from bpy.types import Panel
|
|
|
|
|
|
Import Fix, funcs moved, refs updated, ocl rename
Changed all imports from absolute to relative:
- instead of importing the module 'cam' now imports come from '.' the relative parent folder
- importing the module into itself resulted in a circular import error, relative imports avoid this
Moved Functions, refs updated:
- some functions (and 2 variables) only existed on the base level of the module, in the init file, and could not otherwise be accessed, they were moved into the utils file with other similar functions
- these were primarily called as update functions for Properties scattered across the addon, these have all been updated to reflect the new location and import convention
opencamlib_version rename:
- in 2 files there was a local variable named 'opencamlib_version' that was defined by a function called 'opencamlib_version' that returned the opencamlib_version
- this seemed to confuse Blender into thinking that it was being called before it was defined, and simply changing the variable name to 'ocl_version' while keeping the function name as 'opencamlib_version' fixed the issue
2024-03-22 21:52:18 +00:00
|
|
|
from .buttons_panel import CAMButtonsPanel
|
2022-04-12 09:35:49 +00:00
|
|
|
|
2024-03-21 12:29:30 +00:00
|
|
|
|
2024-04-02 15:07:14 +00:00
|
|
|
class CAM_MACHINE_Panel(CAMButtonsPanel, Panel):
|
2024-04-11 19:06:21 +00:00
|
|
|
"""CAM Machine Panel"""
|
2023-07-04 17:16:13 +00:00
|
|
|
bl_label = "CAM Machine"
|
2022-04-12 09:35:49 +00:00
|
|
|
bl_idname = "WORLD_PT_CAM_MACHINE"
|
2023-06-13 17:51:15 +00:00
|
|
|
always_show_panel = True
|
2023-06-13 18:15:22 +00:00
|
|
|
panel_interface_level = 0
|
2022-04-12 09:35:49 +00:00
|
|
|
|
2023-07-04 17:16:13 +00:00
|
|
|
prop_level = {
|
|
|
|
|
'draw_presets': 1,
|
|
|
|
|
'draw_post_processor': 0,
|
|
|
|
|
'draw_split_files': 2,
|
2023-10-30 16:11:13 +00:00
|
|
|
'draw_system': 0,
|
2023-07-04 17:16:13 +00:00
|
|
|
'draw_position_definitions': 2,
|
2023-10-30 16:11:13 +00:00
|
|
|
'draw_working_area': 0,
|
|
|
|
|
'draw_feedrates': 1,
|
|
|
|
|
'draw_splindle_speeds': 0,
|
2023-07-04 17:16:13 +00:00
|
|
|
'draw_tool_options': 2,
|
2023-10-30 16:11:13 +00:00
|
|
|
'draw_suplemental_axis': 3,
|
2023-07-04 17:16:13 +00:00
|
|
|
'draw_collet_size': 2,
|
|
|
|
|
'draw_block_numbers': 2,
|
2023-10-30 16:11:13 +00:00
|
|
|
'draw_hourly_rate': 1
|
2023-07-04 17:16:13 +00:00
|
|
|
}
|
2022-04-12 09:35:49 +00:00
|
|
|
|
2023-07-04 17:16:13 +00:00
|
|
|
def draw_presets(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
|
return
|
2023-07-04 17:16:13 +00:00
|
|
|
row = self.layout.row(align=True)
|
2024-03-23 15:14:38 +00:00
|
|
|
row.menu("CAM_MACHINE_MT_presets", text=bpy.types.CAM_MACHINE_MT_presets.bl_label)
|
2023-07-04 17:16:13 +00:00
|
|
|
row.operator("render.cam_preset_machine_add", text="", icon='ADD')
|
2024-03-23 15:14:38 +00:00
|
|
|
row.operator("render.cam_preset_machine_add", text="", icon='REMOVE').remove_active = True
|
2023-07-04 17:16:13 +00:00
|
|
|
|
|
|
|
|
def draw_post_processor(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
|
return
|
2023-07-04 17:16:13 +00:00
|
|
|
self.layout.prop(self.machine, 'post_processor')
|
|
|
|
|
|
|
|
|
|
def draw_split_files(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
|
return
|
2023-07-04 17:16:13 +00:00
|
|
|
self.layout.prop(self.machine, 'eval_splitting')
|
|
|
|
|
if self.machine.eval_splitting:
|
|
|
|
|
self.layout.prop(self.machine, 'split_limit')
|
|
|
|
|
|
|
|
|
|
def draw_system(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
|
return
|
2023-07-04 17:16:13 +00:00
|
|
|
self.layout.prop(bpy.context.scene.unit_settings, 'system')
|
|
|
|
|
|
|
|
|
|
def draw_position_definitions(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
|
return
|
2023-07-04 17:16:13 +00:00
|
|
|
self.layout.prop(self.machine, 'use_position_definitions')
|
|
|
|
|
if self.machine.use_position_definitions:
|
|
|
|
|
self.layout.prop(self.machine, 'starting_position')
|
|
|
|
|
self.layout.prop(self.machine, 'mtc_position')
|
|
|
|
|
self.layout.prop(self.machine, 'ending_position')
|
|
|
|
|
|
|
|
|
|
def draw_working_area(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
|
return
|
2023-07-04 17:16:13 +00:00
|
|
|
self.layout.prop(self.machine, 'working_area')
|
|
|
|
|
|
|
|
|
|
def draw_feedrates(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
|
return
|
2023-07-04 17:16:13 +00:00
|
|
|
self.layout.prop(self.machine, 'feedrate_min')
|
|
|
|
|
self.layout.prop(self.machine, 'feedrate_max')
|
|
|
|
|
self.layout.prop(self.machine, 'feedrate_default')
|
|
|
|
|
|
|
|
|
|
def draw_splindle_speeds(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
|
return
|
2023-07-04 17:16:13 +00:00
|
|
|
# TODO: spindle default and feedrate default should become part of the cutter definition...
|
|
|
|
|
self.layout.prop(self.machine, 'spindle_min')
|
|
|
|
|
self.layout.prop(self.machine, 'spindle_max')
|
|
|
|
|
self.layout.prop(self.machine, 'spindle_start_time')
|
|
|
|
|
self.layout.prop(self.machine, 'spindle_default')
|
|
|
|
|
|
|
|
|
|
def draw_tool_options(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
|
return
|
2023-07-04 17:16:13 +00:00
|
|
|
self.layout.prop(self.machine, 'output_tool_definitions')
|
|
|
|
|
self.layout.prop(self.machine, 'output_tool_change')
|
|
|
|
|
if self.machine.output_tool_change:
|
|
|
|
|
self.layout.prop(self.machine, 'output_g43_on_tool_change')
|
|
|
|
|
|
|
|
|
|
def draw_suplemental_axis(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
|
return
|
2023-07-04 17:16:13 +00:00
|
|
|
self.layout.prop(self.machine, 'axis4')
|
|
|
|
|
self.layout.prop(self.machine, 'axis5')
|
|
|
|
|
|
|
|
|
|
def draw_collet_size(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
|
return
|
2023-07-04 17:16:13 +00:00
|
|
|
self.layout.prop(self.machine, 'collet_size')
|
|
|
|
|
|
|
|
|
|
def draw_block_numbers(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
|
return
|
2023-07-04 17:16:13 +00:00
|
|
|
self.layout.prop(self.machine, 'output_block_numbers')
|
|
|
|
|
if self.machine.output_block_numbers:
|
|
|
|
|
self.layout.prop(self.machine, 'start_block_number')
|
|
|
|
|
self.layout.prop(self.machine, 'block_number_increment')
|
|
|
|
|
|
|
|
|
|
def draw_hourly_rate(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
|
return
|
2023-07-04 17:16:13 +00:00
|
|
|
self.layout.prop(self.machine, 'hourly_rate')
|
2022-04-12 09:35:49 +00:00
|
|
|
|
|
|
|
|
def draw(self, context):
|
2023-07-04 17:16:13 +00:00
|
|
|
self.context = context
|
|
|
|
|
self.machine = bpy.context.scene.cam_machine
|
|
|
|
|
|
|
|
|
|
self.draw_presets()
|
|
|
|
|
self.draw_post_processor()
|
|
|
|
|
self.draw_split_files()
|
|
|
|
|
self.draw_system()
|
|
|
|
|
self.draw_position_definitions()
|
|
|
|
|
self.draw_working_area()
|
|
|
|
|
self.draw_feedrates()
|
|
|
|
|
self.draw_splindle_speeds()
|
|
|
|
|
self.draw_tool_options()
|
|
|
|
|
self.draw_suplemental_axis()
|
|
|
|
|
self.draw_collet_size()
|
|
|
|
|
self.draw_block_numbers()
|
|
|
|
|
self.draw_hourly_rate()
|