kopia lustrzana https://github.com/vilemduha/blendercam
Fix for the Profile/On Line and Curve to Path strategies not working when the curve contains splines made of polylines that have 2 points
rodzic
5f00061c70
commit
e3dee63e68
|
@ -841,3 +841,27 @@ def active_to_shapely_poly():
|
|||
"""
|
||||
# convert coordinates to shapely Polygon datastructure
|
||||
return Polygon(active_to_coords())
|
||||
|
||||
|
||||
#checks for curve splines shorter than three points and subdivides if necessary
|
||||
def subdivide_short_lines(co):
|
||||
"""Subdivide all polylines to have at least three points.
|
||||
|
||||
This function iterates through the splines of a curve, checks if they are not bezier
|
||||
and if they have less or equal to two points. If so, each spline is subdivided to get
|
||||
at least three points.
|
||||
|
||||
Args:
|
||||
co (Object): A curve object to be analyzed and modified.
|
||||
"""
|
||||
if bpy.context.active_object.mode != 'EDIT':
|
||||
bpy.ops.object.mode_set(mode="EDIT")
|
||||
for sp in co.data.splines:
|
||||
if len(sp.points) <= 2 and sp.type != 'BEZIER':
|
||||
bpy.ops.curve.select_all(action='DESELECT')
|
||||
for pt in sp.points:
|
||||
pt.select = True
|
||||
bpy.ops.curve.subdivide()
|
||||
if bpy.context.active_object.mode == 'EDIT':
|
||||
bpy.ops.object.editmode_toggle()
|
||||
bpy.ops.object.select_all(action='SELECT')
|
||||
|
|
|
@ -49,6 +49,7 @@ from .simple import (
|
|||
join_multiple,
|
||||
progress,
|
||||
remove_multiple,
|
||||
subdivide_short_lines,
|
||||
)
|
||||
from .utils import (
|
||||
Add_Pocket,
|
||||
|
@ -121,14 +122,10 @@ async def cutout(o):
|
|||
if ob.data.splines[0].type == 'BEZIER':
|
||||
activate(ob)
|
||||
bpy.ops.object.curve_remove_doubles(merg_distance=0.0001, keep_bezier=True)
|
||||
elif len(ob.data.splines[0].points) <= 2:
|
||||
bpy.ops.object.curve_remove_doubles()
|
||||
bpy.ops.object.editmode_toggle()
|
||||
bpy.ops.curve.select_all(action='SELECT')
|
||||
bpy.ops.curve.subdivide()
|
||||
bpy.ops.object.editmode_toggle()
|
||||
else:
|
||||
bpy.ops.object.curve_remove_doubles()
|
||||
#make sure all polylines are at least three points long
|
||||
subdivide_short_lines(ob)
|
||||
|
||||
if o.cut_type == 'ONLINE' and o.onlycurves: # is separate to allow open curves :)
|
||||
print('separate')
|
||||
|
@ -289,6 +286,8 @@ async def curve(o):
|
|||
raise CamException("All Objects Must Be Curves for This Operation.")
|
||||
|
||||
for ob in o.objects:
|
||||
#make sure all polylines are at least three points long
|
||||
subdivide_short_lines(ob)
|
||||
# make the chunks from curve here
|
||||
pathSamples.extend(curveToChunks(ob))
|
||||
# sort before sampling
|
||||
|
|
Ładowanie…
Reference in New Issue