Merge pull request #200 from abosafia/master

straight pocket
pull/273/head
Alain Pelletier 2024-09-30 13:34:16 -03:00 zatwierdzone przez GitHub
commit 1e06ad65da
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
5 zmienionych plików z 39 dodań i 15 usunięć

Wyświetl plik

@ -361,7 +361,7 @@ class camOperation(PropertyGroup):
straight: BoolProperty(
name="Overshoot Style",
description="Use overshoot cutout instead of conventional rounded",
default=False,
default=True,
update=updateRest,
)
# cutter

Wyświetl plik

@ -33,7 +33,8 @@ from . import (
utils,
)
def generate_crosshatch(context, angle, distance, offset, pocket_shape, ob = None):
def generate_crosshatch(context, angle, distance, offset,
pocket_shape,join, ob = None):
"""Execute the crosshatch generation process based on the provided context.
Args:
@ -100,7 +101,7 @@ def generate_crosshatch(context, angle, distance, offset, pocket_shape, ob = Non
if pocket_shape == 'BOUNDS':
xing = translated.intersection(bounds) # Intersection with bounding box
else:
xing = translated.intersection(shapes.buffer(offset)) # Intersection with shapes or hull
xing = translated.intersection(shapes.buffer(offset,join_style=join)) # Intersection with shapes or hull
# Return the intersection result
return xing
@ -135,6 +136,11 @@ class CamCurveHatch(Operator):
default=False,
)
straight: BoolProperty(
name="Overshoot Style",
description="Use overshoot cutout instead of conventional rounded",
default=True,
)
@classmethod
def poll(cls, context):
return context.active_object is not None and context.active_object.type in ['CURVE', 'FONT']
@ -148,11 +154,16 @@ class CamCurveHatch(Operator):
layout.prop(self, 'pocket_shape')
layout.prop(self, 'xhatch')
if self.pocket_shape=='POCKET':
layout.prop(self, 'straight')
layout.prop(self, 'contour')
if self.contour:
layout.prop(self, 'contour_separate')
def execute(self, context):
if self.straight:
join = 2
else:
join = 1
ob = context.active_object
obname = ob.name
ob.select_set(True)
@ -168,6 +179,7 @@ class CamCurveHatch(Operator):
self.distance,
xingOffset,
self.pocket_shape,
join,
)
utils.shapelyToCurve('crosshatch_lines', xing, depth)
@ -179,6 +191,7 @@ class CamCurveHatch(Operator):
self.distance,
xingOffset,
self.pocket_shape,
join,
)
utils.shapelyToCurve('crosshatch_lines_ra', xingra, depth)

Wyświetl plik

@ -590,7 +590,7 @@ class CamCurveRemoveDoubles(Operator):
merge_distance: FloatProperty(
name="Merge distance",
default=0.0001,
min=0.0,
min=0,
max=.01,
)
@ -620,6 +620,7 @@ class CamCurveRemoveDoubles(Operator):
bpy.ops.curve.remove_double(distance=self.merge_distance)
bpy.ops.object.editmode_toggle()
else:
self.merge_distance = 0
if bpy.context.mode == 'EDIT_CURVE':
bpy.ops.object.editmode_toggle()
bpy.ops.object.convert(target='MESH')
@ -637,7 +638,7 @@ class CamCurveRemoveDoubles(Operator):
if obj.type == 'CURVE':
if obj.data.splines and obj.data.splines[0].type == 'BEZIER':
layout.prop(self, "keep_bezier", text="Keep Bezier")
layout.prop(self, "merg_distance", text="Merge Distance")
layout.prop(self, "merge_distance", text="Merge Distance")
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)

Wyświetl plik

@ -418,7 +418,10 @@ async def pocket(o):
None: The function modifies the scene and generates geometry
based on the pocketing operation.
"""
if o.straight:
join = 2
else:
join = 1
print('Operation: Pocket')
scene = bpy.context.scene
@ -453,23 +456,28 @@ async def pocket(o):
offset= -c_offset
pocket_shape = ""
n_angle= angle-pi/2
pr = getObjectOutline(0, o, False)
if o.pocketType == 'PARALLEL':
if o.parallelPocketContour:
offset= -(c_offset+distance/2)
p = getObjectOutline(c_offset, o, False)
p = pr.buffer(-c_offset, resolution = o.optimisation.circle_detail,
join_style = join, mitre_limit = 2)
nchunks = shapelyToChunks(p, o.min.z)
chunksFromCurve.extend(nchunks)
crosshatch_result = generate_crosshatch(bpy.context, angle, distance, offset, pocket_shape, c_ob)
crosshatch_result = generate_crosshatch(bpy.context, angle, distance,
offset, pocket_shape, join, c_ob)
nchunks = shapelyToChunks(crosshatch_result, o.min.z)
chunksFromCurve.extend(nchunks)
if o.parallelPocketCrosshatch:
crosshatch_result = generate_crosshatch(bpy.context, n_angle, distance, offset, pocket_shape, c_ob)
crosshatch_result = generate_crosshatch(bpy.context, n_angle,
distance, offset, pocket_shape,join,c_ob)
nchunks = shapelyToChunks(crosshatch_result, o.min.z)
chunksFromCurve.extend(nchunks)
else:
p = getObjectOutline(c_offset, o, False)
p = pr.buffer(-c_offset, resolution = o.optimisation.circle_detail,
join_style = join, mitre_limit = 2)
approxn = (min(o.max.x - o.min.x, o.max.y - o.min.y) / o.dist_between_paths) / 2
print("Approximative:" + str(approxn))
print(o)
@ -488,11 +496,11 @@ async def pocket(o):
nchunks = shapelyToChunks(p, o.min.z)
# print("nchunks")
pnew = p.buffer(-o.dist_between_paths, o.optimisation.circle_detail)
pnew = p.buffer(-o.dist_between_paths, o.optimisation.circle_detail,join_style=join, mitre_limit=2)
if pnew.is_empty:
# test if the last curve will leave material
pt = p.buffer(-c_offset, o.optimisation.circle_detail)
pt = p.buffer(-c_offset, o.optimisation.circle_detail,join_style=join, mitre_limit=2)
if not pt.is_empty:
pnew = pt
# print("pnew")

Wyświetl plik

@ -95,7 +95,7 @@ class CAM_OPERATION_PROPERTIES_Panel(CAMButtonsPanel, Panel):
if not self.has_correct_level():
return
self.layout.prop(self.op, 'cut_type')
def draw_overshoot(self):
if not self.has_correct_level():
return
@ -131,7 +131,8 @@ class CAM_OPERATION_PROPERTIES_Panel(CAMButtonsPanel, Panel):
return
if self.op.strategy in ['CUTOUT']:
self.draw_cutout_type()
self.draw_overshoot()
if self.op.cut_type in ['OUTSIDE', 'INSIDE']:
self.draw_overshoot()
self.draw_startpoint()
self.draw_lead_in_out()
@ -180,9 +181,10 @@ class CAM_OPERATION_PROPERTIES_Panel(CAMButtonsPanel, Panel):
if not self.has_correct_level():
return
if self.op.strategy in ['POCKET']:
self.draw_overshoot()
self.layout.prop(self.op, 'pocketType')
if self.op.pocketType == 'PARALLEL':
self.layout.label(text="Warning: Experimental", icon='ERROR')
self.layout.label(text="Warning:Parallel pocket Experimental", icon='ERROR')
self.layout.prop(self.op, 'parallelPocketCrosshatch')
self.layout.prop(self.op, 'parallelPocketContour')
self.layout.prop(self.op, 'parallelPocketAngle')