Skip to content

Commit

Permalink
path: vcarve requires engraver with proper angle
Browse files Browse the repository at this point in the history
vcarve calculates depth with MIC now
  • Loading branch information
sliptonic committed Sep 28, 2020
1 parent 0b7eec6 commit 5df1f17
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Mod/Path/Gui/Resources/panels/PageOpVcarveEdit.ui
Expand Up @@ -68,13 +68,13 @@
<number>4</number>
</property>
<property name="minimum">
<double>0.001000000000000</double>
<double>0.000100000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.001000000000000</double>
<double>0.000100000000000</double>
</property>
<property name="value">
<double>0.010000000000000</double>
Expand Down
20 changes: 17 additions & 3 deletions src/Mod/Path/PathScripts/PathVcarve.py
Expand Up @@ -34,7 +34,7 @@
import time
import PathScripts.PathGeom as pg
from PathScripts.PathOpTools import orientWire

import math

from PySide import QtCore

Expand Down Expand Up @@ -104,6 +104,7 @@ def insert_many_wires(vd, wires):
polygon_ids =[]
t_before = time.time()
for idx, wire in enumerate(wires):
print('discretize: {}'.format(obj.Discretize))
pointList = wire.discretize(Deflection=obj.Discretize)
segwire = Part.Wire([Part.makeLine(p[0],p[1]) for p in zip(pointList, pointList[1:] )])

Expand All @@ -124,9 +125,14 @@ def insert_many_wires(vd, wires):
seg_time = t_after-t_before
return [pt_time, seg_time]

def calculate_depth(MIC):
# given a maximum inscribed circle (MIC) and tool angle,
# return depth of cut.
toolangle = obj.ToolController.Tool.CuttingEdgeAngle
return MIC / math.tan(math.radians(toolangle/2))

def buildMedial(vd):
safeheight = 3.0
safeheight = obj.SafeHeight.Value
path = []
maw = ovd.MedialAxisWalk( vd.getGraph() )
toolpath = maw.walk()
Expand All @@ -140,7 +146,7 @@ def buildMedial(vd):
for step in chain:
for point in step:
p = point[0]
z = -(point[1])
z = calculate_depth(-(point[1]))
path.append(Path.Command("G1 X{} Y{} Z{}".format(p.x, p.y, z)))

path.append(Path.Command("G0 Z{}".format(safeheight)))
Expand Down Expand Up @@ -183,7 +189,15 @@ def opExecute(self, obj):
jobshapes = []
zValues = self.getZValues(obj)

if obj.ToolController.Tool.ToolType != 'Engraver':
FreeCAD.Console.PrintError(
translate("Path_Vcarve", "This operation requires an engraver tool.") + "\n")
return

if obj.ToolController.Tool.CuttingEdgeAngle >= 180.0:
FreeCAD.Console.PrintError(
translate("Path_Vcarve", "Engraver Cutting Edge Angle must be < 180 degrees.") + "\n")
return
try:
if len(self.model) == 1 and self.model[0].isDerivedFrom('Sketcher::SketchObject') or \
self.model[0].isDerivedFrom('Part::Part2DObject'):
Expand Down

0 comments on commit 5df1f17

Please sign in to comment.