Fixed chamfer depth and cleaned up properties.

This commit is contained in:
Markus Lampert
2018-06-12 21:49:38 -07:00
parent 50da8c2044
commit 014e7b5cd2
4 changed files with 62 additions and 47 deletions

View File

@@ -557,9 +557,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.8533932"
inkscape:cx="-156.17498"
inkscape:cy="193.24781"
inkscape:zoom="20.96875"
inkscape:cx="31.95231"
inkscape:cy="32"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
@@ -595,7 +595,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:title />
<dc:title>Path-Drilling</dc:title>
<dc:date>2015-07-04</dc:date>
<dc:relation>http://www.freecadweb.org/wiki/index.php?title=Artwork</dc:relation>
@@ -625,19 +625,19 @@
inkscape:groupmode="layer">
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient4036);fill-opacity:1;fill-rule:nonzero;stroke:#0b1521;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
d="M 2.88,41.92 3,61 39.36,61.12 V 48.64 L 28.8,41.92 Z"
d="M 2.88,19.84 3,61 l 54.6,0.12 0,-12.48 -30.72,-28.8 z"
id="rect3085"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccc" />
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#729fcf;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
d="M 4.8,43.84 5,59 37.44,59.2 v -9.6 l -9.6,-5.76 z"
d="M 4.8,21.76 5,59 l 50.68,0.2 0,-9.6 -29.76,-27.84 z"
id="rect3085-7"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccc" />
<g
id="g3908-1-4"
transform="matrix(1.2383679,0,0,1,-51.54617,-12)">
transform="matrix(1.2383679,0,0,1,-39.034237,-12.932697)">
<g
id="g3135">
<g
@@ -647,14 +647,14 @@
id="g3126-1-1"
style="fill:url(#linearGradient3147);fill-opacity:1">
<path
style="color:#000000;fill:url(#linearGradient3143);fill-opacity:1;fill-rule:nonzero;stroke:#2e3436;stroke-width:2.02702332;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="m 22.755149,28 0,9 18.489706,-8 0,-9 z m 18.489706,3 -18.489706,8 0,9 18.489706,-8 z m 0,11 L 22.755149,50 32,56 41.244855,50 z"
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient3143);fill-opacity:1;fill-rule:nonzero;stroke:#2e3436;stroke-width:2.02702332;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
d="m 22.755149,28 v 9 l 18.489706,-8 v -9 z m 18.489706,3 -18.489706,8 v 9 l 18.489706,-8 z m 0,11 L 22.755149,50 32,56 41.244855,50 Z"
id="rect4417-1-2"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccccccccc" />
<path
style="fill:url(#linearGradient3145);fill-opacity:1;stroke:#2e3436;stroke-width:2.02702332;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
d="m 22.755149,26 0,-14 18.489706,0 0,6 z"
d="M 22.755149,26 V 12 h 18.489706 v 6 z"
id="path3085-5-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
@@ -664,11 +664,11 @@
inkscape:connector-curvature="0"
id="rect4417-1-4-2-3"
d="m 24.826699,29.299103 0.02839,4.492034 14.320401,-6.092914 0.02324,-4.645526 z m 14.361546,4.789285 -14.374245,6.229006 0.01513,4.5902 14.389879,-6.224988 z m -0.01949,10.999765 -12.158366,5.23507 4.97403,3.277297 7.174659,-4.659288 z"
style="color:#000000;fill:none;stroke:#d3d7cf;stroke-width:2.02702332;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#d3d7cf;stroke-width:2.02702332;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" />
</g>
<path
style="fill:none;stroke:#d3d7cf;stroke-width:1.7972362;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 68.272256,17 0.014,8.948166 L 79.576261,19.762958 79.577458,17 z"
d="m 68.272256,17 0.014,8.948166 L 79.576261,19.762958 79.577458,17 Z"
id="path3906-7-4"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -46,35 +46,25 @@ class ObjectChamfer(PathEngraveBase.ObjectOp):
'''Proxy class for Chamfer operation.'''
def opFeatures(self, obj):
return PathOp.FeatureTool | PathOp.FeatureDepths | PathOp.FeatureHeights | PathOp.FeatureStepDown | PathOp.FeatureBaseEdges | PathOp.FeatureBaseFaces;
return PathOp.FeatureTool | PathOp.FeatureHeights | PathOp.FeatureBaseEdges | PathOp.FeatureBaseFaces
def initOperation(self, obj):
obj.addProperty("App::PropertyDistance", "Width", "Chamfer", QtCore.QT_TRANSLATE_NOOP("PathChamfer", "The desired width of the chamfer"))
obj.addProperty("App::PropertyDistance", "ExtraDepth", "Chamfer", QtCore.QT_TRANSLATE_NOOP("PathChamfer", "The additional depth of the tool path"))
def opUpdateDepths(self, obj, ignoreErrors=False):
angle = obj.ToolController.Tool.CuttingEdgeAngle
if 0 == angle:
angle = 180
tan = math.tan(math.radians(angle/2))
toolDepth = 0 if 0 == tan else obj.Width.Value / tan
extraDepth = obj.ExtraDepth.Value
depth = toolDepth + extraDepth
obj.OpFinalDepth = depth
if obj.OpStartDepth < obj.OpFinalDepth:
obj.OpStartDepth = obj.OpFinalDepth + 1
def opExecute(self, obj):
angle = self.tool.CuttingEdgeAngle
if 0 == angle:
angle = 180
tan = math.tan(math.radians(angle/2))
toolDepth = 0 if 0 == tan else obj.Width.Value / tan
extraDepth = obj.ExtraDepth.Value
depth = toolDepth + extraDepth
toolOffset = self.tool.FlatRadius
extraOffset = self.tool.Diameter/2 - obj.Width.Value if 180 == angle else obj.ExtraDepth.Value / tan
offset = toolOffset + extraOffset
zValues = self.getZValues(obj)
wires = []
for base, subs in obj.Base:
edges = []
@@ -93,7 +83,7 @@ class ObjectChamfer(PathEngraveBase.ObjectOp):
for w in self.adjustWirePlacement(obj, base, basewires):
wires.append(self.offsetWire(w, base, offset))
self.wires = wires
self.buildpathocc(obj, wires, zValues)
self.buildpathocc(obj, wires, [depth], True)
def offsetWire(self, wire, base, offset):
def removeInsideEdges(edges):

View File

@@ -29,6 +29,7 @@ import Path
import PathScripts.PathLog as PathLog
import PathScripts.PathOp as PathOp
import PathScripts.PathUtils as PathUtils
import copy
from PathScripts.PathGeom import PathGeom
from PySide import QtCore
@@ -60,8 +61,8 @@ class ObjectOp(PathOp.ObjectOp):
self.zValues = zValues
return zValues
def buildpathocc(self, obj, wires, zValues):
'''buildpathocc(obj, wires, zValues) ... internal helper function to generate engraving commands.'''
def buildpathocc(self, obj, wires, zValues, rel=False):
'''buildpathocc(obj, wires, zValues, rel=False) ... internal helper function to generate engraving commands.'''
PathLog.track(obj.Label, len(wires), zValues)
for wire in wires:
@@ -71,54 +72,67 @@ class ObjectOp(PathOp.ObjectOp):
if hasattr(obj, 'StartVertex'):
offset = DraftGeomUtils.rebaseWire(offset, obj.StartVertex)
edges = copy.copy(offset.Edges)
last = None
for z in zValues:
if last:
self.commandlist.append(Path.Command('G1', {'X': last.x, 'Y': last.y, 'Z': z, 'F': self.vertFeed}))
if rel:
self.commandlist.append(Path.Command('G1', {'X': last.x, 'Y': last.y, 'Z': last.z - z, 'F': self.vertFeed}))
else:
self.commandlist.append(Path.Command('G1', {'X': last.x, 'Y': last.y, 'Z': z, 'F': self.vertFeed}))
for edge in offset.Edges:
for edge in edges:
if not last:
# we set the first move to our first point
last = edge.Vertexes[0].Point
if len(offset.Edges) > 1:
ve = edge.Vertexes[-1]
e2 = offset.Edges[1]
if not PathGeom.pointsCoincide(edge.Vertexes[-1].Point, e2.Vertexes[0].Point) and not PathGeom.pointsCoincide(edge.Vertexes[-1].Point, e2.Vertexes[-1].Point):
if not PathGeom.pointsCoincide(ve.Point, e2.Vertexes[0].Point) and not PathGeom.pointsCoincide(ve.Point, e2.Vertexes[-1].Point):
PathLog.debug("flip first edge")
last = edge.Vertexes[-1].Point
else:
PathLog.debug("original first edge")
else:
PathLog.debug("not enough edges to flip")
self.commandlist.append(Path.Command('G0', {'X': last.x, 'Y': last.y, 'Z': obj.ClearanceHeight.Value, 'F': self.horizRapid}))
self.commandlist.append(Path.Command('G0', {'X': last.x, 'Y': last.y, 'Z': obj.SafeHeight.Value, 'F': self.vertRapid}))
self.commandlist.append(Path.Command('G0', {'X': last.x, 'Y': last.y, 'Z': z, 'F': self.vertFeed}))
if rel:
self.commandlist.append(Path.Command('G1', {'X': last.x, 'Y': last.y, 'Z': last.z - z, 'F': self.vertFeed}))
else:
self.commandlist.append(Path.Command('G1', {'X': last.x, 'Y': last.y, 'Z': z, 'F': self.vertFeed}))
if PathGeom.pointsCoincide(last, edge.Vertexes[0].Point):
for cmd in PathGeom.cmdsForEdge(edge):
params = cmd.Parameters
params.update({'Z': z, 'F': self.horizFeed})
self.commandlist.append(Path.Command(cmd.Name, params))
self.appendCommand(cmd, z, rel)
last = edge.Vertexes[-1].Point
else:
for cmd in PathGeom.cmdsForEdge(edge, True):
params = cmd.Parameters
params.update({'Z': z, 'F': self.horizFeed})
self.commandlist.append(Path.Command(cmd.Name, params))
self.appendCommand(cmd, z, rel)
last = edge.Vertexes[0].Point
self.commandlist.append(Path.Command('G0', {'Z': obj.ClearanceHeight.Value, 'F': self.vertRapid}))
if self.commandlist:
self.commandlist.pop()
def appendCommand(self, cmd, z, rel):
params = cmd.Parameters
if rel:
z = params['Z'] - z
params.update({'Z': z, 'F': self.horizFeed})
self.commandlist.append(Path.Command(cmd.Name, params))
def opSetDefaultValues(self, obj):
'''opSetDefaultValues(obj) ... set depths for engraving'''
job = PathUtils.findParentJob(obj)
if job and job.Base:
bb = job.Base.Shape.BoundBox
obj.OpStartDepth = bb.ZMax
obj.OpFinalDepth = bb.ZMax - max(obj.StepDown.Value, 0.1)
else:
obj.OpFinalDepth = -0.1
if PathOp.FeatureDepths & self.opFeatures(obj):
job = PathUtils.findParentJob(obj)
if job and job.Base:
bb = job.Base.Shape.BoundBox
obj.OpStartDepth = bb.ZMax
obj.OpFinalDepth = bb.ZMax - max(obj.StepDown.Value, 0.1)
else:
obj.OpFinalDepth = -0.1
def adjustWirePlacement(self, obj, shape, wires):
job = PathUtils.findParentJob(obj)

View File

@@ -132,6 +132,10 @@ class ObjectOp(object):
if FeatureNoFinalDepth & features:
obj.setEditorMode('FinalDepth', 2) # hide
self.addOpValues(obj, ['start', 'final'])
else:
# StartDepth has become necessary for expressions on other properties
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "Starting Depth internal use only for derived values"))
obj.setEditorMode('StartDepth', 1) # read-only
if FeatureStepDown & features:
obj.addProperty("App::PropertyDistance", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "Incremental Step Down of Tool"))
@@ -258,6 +262,8 @@ class ObjectOp(object):
obj.OpFinalDepth = 0.0
else:
obj.FinalDepth = 0.0
else:
obj.StartDepth = 1.0
if FeatureStepDown & features:
if not self.applyExpression(obj, 'StepDown', job.SetupSheet.StepDownExpression):
@@ -355,6 +361,11 @@ class ObjectOp(object):
# update start depth if requested and required
if not PathGeom.isRoughly(obj.OpStartDepth.Value, zmax):
obj.OpStartDepth = zmax
else:
# every obj has a StartDepth
if obj.StartDepth.Value != zmax:
obj.StartDepth = zmax
self.opUpdateDepths(obj)
@waiting_effects