Skip to content

Commit

Permalink
Merge pull request #159 from SpectralVectors/pie-menu
Browse files Browse the repository at this point in the history
Pie Menu, Curve Create Name, bl_info Update
  • Loading branch information
pppalain authored Apr 12, 2024
2 parents 32a30b6 + 94015bc commit e6d30e2
Show file tree
Hide file tree
Showing 18 changed files with 1,474 additions and 7 deletions.
60 changes: 57 additions & 3 deletions scripts/addons/cam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@
timer_update,
)
from .pack import PackObjectsSettings
from .pie_menu.pie_cam import VIEW3D_MT_PIE_CAM
from .pie_menu.pie_chains import VIEW3D_MT_PIE_Chains
from .pie_menu.pie_curvecreators import VIEW3D_MT_PIE_CurveCreators
from .pie_menu.pie_curvetools import VIEW3D_MT_PIE_CurveTools
from .pie_menu.pie_info import VIEW3D_MT_PIE_Info
from .pie_menu.pie_machine import VIEW3D_MT_PIE_Machine
from .pie_menu.pie_material import VIEW3D_MT_PIE_Material
from .pie_menu.pie_pack_slice_relief import VIEW3D_MT_PIE_PackSliceRelief
from .pie_menu.active_op.pie_area import VIEW3D_MT_PIE_Area
from .pie_menu.active_op.pie_cutter import VIEW3D_MT_PIE_Cutter
from .pie_menu.active_op.pie_feedrate import VIEW3D_MT_PIE_Feedrate
from .pie_menu.active_op.pie_gcode import VIEW3D_MT_PIE_Gcode
from .pie_menu.active_op.pie_movement import VIEW3D_MT_PIE_Movement
from .pie_menu.active_op.pie_operation import VIEW3D_MT_PIE_Operation
from .pie_menu.active_op.pie_optimisation import VIEW3D_MT_PIE_Optimisation
from .pie_menu.active_op.pie_setup import VIEW3D_MT_PIE_Setup
from .preferences import CamAddonPreferences
from .preset_managers import (
AddPresetCamCutter,
Expand Down Expand Up @@ -181,12 +197,12 @@


bl_info = {
"name": "CAM - gcode generation tools",
"name": "BlenderCAM - G-code Generation Tools",
"author": "Vilem Novak & Contributors",
"version":(1,0,18),
"version": (1, 0, 18),
"blender": (3, 6, 0),
"location": "Properties > render",
"description": "Generate machining paths for CNC",
"description": "Generate Machining Paths for CNC",
"warning": "",
"doc_url": "https://blendercam.com/",
"tracker_url": "",
Expand Down Expand Up @@ -314,6 +330,24 @@
CustomPanel,
WM_OT_gcode_import,

# .pie_menu and .pie_menu.active_op - placed after .ui in case inheritance is possible
VIEW3D_MT_PIE_CAM,
VIEW3D_MT_PIE_Machine,
VIEW3D_MT_PIE_Material,
VIEW3D_MT_PIE_Operation,
VIEW3D_MT_PIE_Chains,
VIEW3D_MT_PIE_Setup,
VIEW3D_MT_PIE_Optimisation,
VIEW3D_MT_PIE_Area,
VIEW3D_MT_PIE_Movement,
VIEW3D_MT_PIE_Feedrate,
VIEW3D_MT_PIE_Cutter,
VIEW3D_MT_PIE_Gcode,
VIEW3D_MT_PIE_Info,
VIEW3D_MT_PIE_PackSliceRelief,
VIEW3D_MT_PIE_CurveCreators,
VIEW3D_MT_PIE_CurveTools,

# .cam_operation - last to allow dependencies to register before it
camOperation,
]
Expand Down Expand Up @@ -366,6 +400,19 @@ def register() -> None:
for panel in get_panels():
panel.COMPAT_ENGINES.add("BLENDERCAM_RENDER")

wm = bpy.context.window_manager
addon_kc = wm.keyconfigs.addon

km = addon_kc.keymaps.new(name='Object Mode')
kmi = km.keymap_items.new(
"wm.call_menu_pie",
'C',
'PRESS',
alt=True,
)
kmi.properties.name = 'VIEW3D_MT_PIE_CAM'
kmi.active = True


def unregister() -> None:
for cls in classes:
Expand All @@ -389,3 +436,10 @@ def unregister() -> None:
for panel in get_panels():
if 'BLENDERCAM_RENDER' in panel.COMPAT_ENGINES:
panel.COMPAT_ENGINES.remove('BLENDERCAM_RENDER')

wm = bpy.context.window_manager
active_kc = wm.keyconfigs.active

for key in active_kc.keymaps['Object Mode'].keymap_items:
if (key.idname == 'wm.call_menu' and key.properties.name == 'VIEW3D_MT_PIE_CAM'):
active_kc.keymaps['Object Mode'].keymap_items.remove(key)
8 changes: 4 additions & 4 deletions scripts/addons/cam/curvecamequation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
class CamSineCurve(bpy.types.Operator):
"""Object Sine """ # by Alain Pelletier april 2021
bl_idname = "object.sine"
bl_label = "Create Periodic Wave"
bl_label = "Periodic Wave"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}

# zstring: StringProperty(name="Z equation", description="Equation for z=F(u,v)", default="0.05*sin(2*pi*4*t)" )
Expand Down Expand Up @@ -195,7 +195,7 @@ def f(t, offset: float = 0.0, angle_offset: float = 0.0):
class CamLissajousCurve(bpy.types.Operator):
"""Lissajous """ # by Alain Pelletier april 2021
bl_idname = "object.lissajous"
bl_label = "Create Lissajous Figure"
bl_label = "Lissajous Figure"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}

amplitude_A: FloatProperty(
Expand Down Expand Up @@ -332,7 +332,7 @@ def f(t, offset: float = 0.0):
class CamHypotrochoidCurve(bpy.types.Operator):
"""Hypotrochoid """ # by Alain Pelletier april 2021
bl_idname = "object.hypotrochoid"
bl_label = "Create Spirograph Type Figure"
bl_label = "Spirograph Type Figure"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}

typecurve: EnumProperty(
Expand Down Expand Up @@ -426,7 +426,7 @@ def f(t, offset: float = 0.0):
class CamCustomCurve(bpy.types.Operator):
"""Object Custom Curve """ # by Alain Pelletier april 2021
bl_idname = "object.customcurve"
bl_label = "Create Custom Curve"
bl_label = "Custom Curve"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}

xstring: StringProperty(
Expand Down
90 changes: 90 additions & 0 deletions scripts/addons/cam/pie_menu/active_op/pie_area.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import bpy
from bpy.types import Menu


class VIEW3D_MT_PIE_Area(Menu):
# label is displayed at the center of the pie menu.
bl_label = "∴ Operation Area ∴"

def draw(self, context):
scene = context.scene
operation = scene.cam_operations[scene.cam_active_operation]
material = operation.material

layout = self.layout
# layout.use_property_split = True
layout.use_property_decorate = False

pie = layout.menu_pie()

# Left
box = pie.box()
column = box.column(align=True)
col = column.column(align=True)
row = col.row(align=True)
row.prop(operation, 'use_layers')
if operation.use_layers:
row.prop(operation, 'stepdown')

if operation.strategy in ['CUTOUT', 'POCKET', 'MEDIAL_AXIS']:
row = col.row(align=True)
row.label(text="")
row.prop(operation, 'first_down')

# Right
box = pie.box()
column = box.column(align=True)
if operation.geometry_source in ['OBJECT', 'COLLECTION']:
if operation.strategy == 'CURVE':
column.label(text="Cannot Use Depth from Object Using Curves")

row = column.row(align=True)
row.label(text='Max Depth from')
row.prop(operation, 'minz_from', text='')
if operation.minz_from == 'CUSTOM':
column.prop(operation, 'minz')

else:
column.prop(operation, 'source_image_scale_z')
column.prop(operation, 'source_image_size_x')
if operation.source_image_name != '':
i = bpy.data.images[operation.source_image_name]
if i is not None:
sy = int((operation.source_image_size_x /
i.size[0]) * i.size[1] * 1000000) / 1000
column.label(text='Image Size on Y Axis: ' + strInUnits(sy, 8))
column.separator()
column.prop(operation, 'source_image_offset')
col = column.column(align=True)
col.prop(operation, 'source_image_crop', text='Crop Source Image')
if operation.source_image_crop:
col.prop(operation, 'source_image_crop_start_x', text='start x')
col.prop(operation, 'source_image_crop_start_y', text='start y')
col.prop(operation, 'source_image_crop_end_x', text='end x')
col.prop(operation, 'source_image_crop_end_y', text='end y')

# Bottom
box = pie.box()
column = box.column(align=True)
if operation.strategy in ['BLOCK', 'SPIRAL', 'CIRCLES', 'PARALLEL', 'CROSS']:
column.prop(operation, 'ambient_behaviour')
if operation.ambient_behaviour == 'AROUND':
column.prop(operation, 'ambient_radius')
column.prop(operation, "ambient_cutter_restrict")

if operation.strategy in ['BLOCK', 'SPIRAL', 'CIRCLES', 'PARALLEL', 'CROSS']:
column.prop(operation, 'use_limit_curve')
if operation.use_limit_curve:
column.prop_search(operation, "limit_curve", bpy.data, "objects")

# Top
column = pie.column()
box = column.box()
box.scale_y = 2
box.scale_x = 2
box.emboss = 'NONE'
box.operator(
"wm.call_menu_pie",
text='',
icon='BACK'
).name = 'VIEW3D_MT_PIE_Operation'
104 changes: 104 additions & 0 deletions scripts/addons/cam/pie_menu/active_op/pie_cutter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import bpy
from bpy.types import Menu


class VIEW3D_MT_PIE_Cutter(Menu):
# label is displayed at the center of the pie menu.
bl_label = "∴ Operation Cutter ∴"

def draw(self, context):
scene = context.scene
operation = scene.cam_operations[scene.cam_active_operation]
material = operation.material

layout = self.layout
# layout.use_property_split = True
layout.use_property_decorate = False

pie = layout.menu_pie()

# Left
box = pie.box()
column = box.column(align=True)
row = column.row(align=True)
row.menu("CAM_CUTTER_MT_presets", text=bpy.types.CAM_CUTTER_MT_presets.bl_label)
row.operator("render.cam_preset_cutter_add", text="", icon='ADD')
row.operator("render.cam_preset_cutter_add", text="", icon='REMOVE').remove_active = True
column.prop(operation, 'cutter_id')

column.prop(operation, 'cutter_type')

if operation.cutter_type in ['BALLCONE']:
column.prop(operation, 'ball_radius')

if operation.cutter_type in ['BULLNOSE']:
column.prop(operation, 'bull_corner_radius')

if operation.cutter_type in ['CYLCONE']:
column.prop(operation, 'cylcone_diameter')

if operation.cutter_type in ['VCARVE', 'BALLCONE', 'BULLNOSE', 'CYLCONE']:
column.prop(operation, 'cutter_tip_angle')

if operation.cutter_type in ['LASER']:
column.prop(operation, 'Laser_on')
column.prop(operation, 'Laser_off')
column.prop(operation, 'Laser_cmd')
column.prop(operation, 'Laser_delay')

if operation.cutter_type in ['PLASMA']:
column.prop(operation, 'Plasma_on')
column.prop(operation, 'Plasma_off')
column.prop(operation, 'Plasma_delay')
column.prop(operation, 'Plasma_dwell')
column.prop(operation, 'lead_in')
column.prop(operation, 'lead_out')

if operation.cutter_type in ['CUSTOM']:
if operation.optimisation.use_exact:
column.label(
text='Warning - only Convex Shapes Are Supported. ', icon='COLOR_RED')
column.label(text='If Your Custom Cutter Is Concave,')
column.label(text='Switch Exact Mode Off.')
column.prop_search(operation, "cutter_object_name", bpy.data, "objects")

column.prop(operation, 'cutter_diameter')

if operation.cutter_type not in ['LASER', 'PLASMA']:
column.prop(operation, 'cutter_flutes')

column.prop(operation, 'cutter_description')

# Right
box = pie.box()
column = box.column(align=True)
if operation.cutter_type in ['LASER', 'PLASMA']:
return
if operation.strategy in ['CUTOUT']:
return

if operation.cutter_type in ['BALLCONE']:
engagement = round(100 * operation.dist_between_paths / operation.ball_radius, 1)
else:
engagement = round(100 * operation.dist_between_paths / operation.cutter_diameter, 1)

column.label(text=f"Cutter Engagement: {engagement}%")

if engagement > 50:
column.label(text="WARNING: CUTTER ENGAGEMENT > 50%")

# Bottom
row = pie.row()
row.label(text='')

# Top
column = pie.column()
box = column.box()
box.scale_y = 2
box.scale_x = 2
box.emboss = 'NONE'
box.operator(
"wm.call_menu_pie",
text='',
icon='BACK'
).name = 'VIEW3D_MT_PIE_Operation'
47 changes: 47 additions & 0 deletions scripts/addons/cam/pie_menu/active_op/pie_feedrate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import bpy
from bpy.types import Menu


class VIEW3D_MT_PIE_Feedrate(Menu):
# label is displayed at the center of the pie menu.
bl_label = "∴ Operation Feedrate ∴"

def draw(self, context):
scene = context.scene
operation = scene.cam_operations[scene.cam_active_operation]
material = operation.material

layout = self.layout
# layout.use_property_split = True
layout.use_property_decorate = False

pie = layout.menu_pie()

# Left
box = pie.box()
column = box.column(align=True)
column.prop(operation, 'feedrate')
column.prop(operation, 'do_simulation_feedrate')

# Right
box = pie.box()
column = box.column(align=True)
column.prop(operation, 'plunge_feedrate')
column.prop(operation, 'plunge_angle')
column.prop(operation, 'spindle_rpm')

# Bottom
row = pie.row()
row.label(text='')

# Top
column = pie.column()
box = column.box()
box.scale_y = 2
box.scale_x = 2
box.emboss = 'NONE'
box.operator(
"wm.call_menu_pie",
text='',
icon='BACK'
).name = 'VIEW3D_MT_PIE_Operation'
Loading

0 comments on commit e6d30e2

Please sign in to comment.