Path: additional functionality for arch panels

This commit is contained in:
sliptonic
2017-03-17 19:34:07 -05:00
committed by Yorik van Havre
parent 8699d14057
commit ffc4fb28aa
6 changed files with 134 additions and 102 deletions

View File

@@ -34,7 +34,7 @@ import ArchPanel
LOG_MODULE = 'PathContour'
PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE)
PathLog.trackModule('PathContour')
#PathLog.trackModule('PathContour')
if FreeCAD.GuiUp:
import FreeCADGui

View File

@@ -116,7 +116,6 @@ class ObjectPathEngrave:
baseobject = parentJob.Base
if baseobject is None:
return
try:
if baseobject.isDerivedFrom('Sketcher::SketchObject') or \
baseobject.isDerivedFrom('Part::Part2DObject'):
@@ -132,31 +131,14 @@ class ObjectPathEngrave:
output += self.buildpathocc(obj, wires)
elif isinstance(baseobject.Proxy, ArchPanel.PanelSheet): # process the sheet
baseobject.Proxy.execute(baseobject)
ss = baseobject.Proxy.sheettag
ss.Placement = baseobject.Placement.multiply(ss.Placement)
output += "G0 Z" + PathUtils.fmt(obj.ClearanceHeight.Value) + "F " + PathUtils.fmt(self.vertRapid) + "\n"
for w in ss.Wires:
tempedges = PathUtils.cleanedges(w.Edges, 0.5)
wires.append(Part.Wire(tempedges))
if obj.Algorithm == "OCC Native":
output += self.buildpathocc(obj, wires)
for subobj in baseobject.Group: # process the group of panels
if isinstance(subobj.Proxy, ArchPanel.PanelCut):
subobj.Proxy.execute(subobj)
if hasattr(subobj.Proxy, "tag"):
ss = subobj.Proxy.tag
ss.Placement = subobj.Placement.multiply(ss.Placement)
output += "G0 Z" + PathUtils.fmt(obj.ClearanceHeight.Value) + "F " + PathUtils.fmt(self.vertRapid) + "\n"
for w in ss.Wires:
tempedges = PathUtils.cleanedges(w.Edges, 0.5)
wires.append(Part.Wire(tempedges))
if obj.Algorithm == "OCC Native":
output += self.buildpathocc(obj, wires)
shapes = baseobject.Proxy.getTags(baseobject)
for shape in shapes:
output += "G0 Z" + PathUtils.fmt(obj.ClearanceHeight.Value) + "F " + PathUtils.fmt(self.vertRapid) + "\n"
for w in shape.Wires:
tempedges = PathUtils.cleanedges(w.Edges, 0.5)
wires.append(Part.Wire(tempedges))
if obj.Algorithm == "OCC Native":
output += self.buildpathocc(obj, wires)
else:
raise ValueError('Unknown baseobject type for engraving')

View File

@@ -26,13 +26,15 @@ import FreeCAD
import Path
import numpy
import TechDraw
import ArchPanel
from FreeCAD import Vector
from PathScripts import PathUtils
from PathScripts.PathUtils import depth_params
import PathScripts.PathLog as PathLog
LOG_MODULE = 'PathProfile'
PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE)
PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE)
# PathLog.trackModule('PathProfile')
if FreeCAD.GuiUp:
@@ -99,6 +101,7 @@ class ObjectProfile:
obj.addProperty("App::PropertyDistance", "OffsetExtra", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Extra value to stay away from final profile- good for roughing toolpath"))
obj.addProperty("App::PropertyBool", "processHoles", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Profile holes as well as the outline"))
obj.addProperty("App::PropertyBool", "processPerimeter", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Profile the outline"))
obj.addProperty("App::PropertyBool", "processCircles", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Profile round holes"))
obj.Proxy = self
@@ -109,8 +112,7 @@ class ObjectProfile:
return None
def onChanged(self, obj, prop):
if prop == "UserLabel":
obj.Label = obj.UserLabel + " :" + obj.ToolDescription
pass
def addprofilebase(self, obj, ss, sub=""):
baselist = obj.Base
@@ -271,6 +273,40 @@ print "y - " + str(point.y)
edgelist = Part.__sortEdges__(edgelist)
output += self._buildPathLibarea(obj, edgelist, False)
else: #Try to build targets frorm the job base
parentJob = PathUtils.findParentJob(obj)
if parentJob is None:
return
baseobject = parentJob.Base
if baseobject is None:
return
if hasattr(baseobject, "Proxy"):
if isinstance(baseobject.Proxy, ArchPanel.PanelSheet): # process the sheet
if obj.processPerimeter:
shapes = baseobject.Proxy.getOutlines(baseobject, transform=False)
for shape in shapes:
for wire in shape.Wires:
edgelist = wire.Edges
edgelist = Part.__sortEdges__(edgelist)
PathLog.debug("Processing panel perimeter. edges found: {}".format(len(edgelist)))
try:
output += self._buildPathLibarea(obj, edgelist, isHole=False)
except:
FreeCAD.Console.PrintError("Something unexpected happened. Unable to generate a contour path. Check project and tool config.")
shapes = baseobject.Proxy.getHoles(baseobject, transform=False)
for shape in shapes:
for wire in shape.Wires:
drillable = PathUtils.isDrillable(baseobject.Proxy, wire)
if (drillable and obj.processCircles) or (not drillable and obj.processHoles):
edgelist = wire.Edges
edgelist = Part.__sortEdges__(edgelist)
try:
output += self._buildPathLibarea(obj, edgelist, isHole=True)
except:
FreeCAD.Console.PrintError("Something unexpected happened. Unable to generate a contour path. Check project and tool config.")
if obj.Active:
path = Path.Path(output)
obj.Path = path
@@ -442,6 +478,8 @@ class TaskPanel:
self.obj.processHoles = self.form.processHoles.isChecked()
if hasattr(self.obj, "processPerimeter"):
self.obj.processPerimeter = self.form.processPerimeter.isChecked()
if hasattr(self.obj, "processCircles"):
self.obj.processCircles = self.form.processCircles.isChecked()
if hasattr(self.obj, "ToolController"):
PathLog.debug("name: {}".format(self.form.uiToolController.currentText()))
tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText())
@@ -462,6 +500,7 @@ class TaskPanel:
self.form.useEndPoint.setChecked(self.obj.UseEndPoint)
self.form.processHoles.setChecked(self.obj.processHoles)
self.form.processPerimeter.setChecked(self.obj.processPerimeter)
self.form.processCircles.setChecked(self.obj.processCircles)
index = self.form.cutSide.findText(
self.obj.Side, QtCore.Qt.MatchFixedString)
@@ -602,6 +641,7 @@ class TaskPanel:
self.form.rollRadius.editingFinished.connect(self.getFields)
self.form.processHoles.clicked.connect(self.getFields)
self.form.processPerimeter.clicked.connect(self.getFields)
self.form.processCircles.clicked.connect(self.getFields)
self.setFields()

View File

@@ -93,6 +93,7 @@ def isDrillable(obj, candidate):
if (round(face.ParameterRange[0], 8) == 0.0) and (round(face.ParameterRange[1], 8) == round(math.pi * 2, 8)):
for edge in face.Edges: # Find seam edge and check if aligned to Z axis.
if (isinstance(edge.Curve, Part.Line)):
PathLog.debug("candidate is a circle")
v0 = edge.Vertexes[0].Point
v1 = edge.Vertexes[1].Point
if (v1.sub(v0).x == 0) and (v1.sub(v0).y == 0):
@@ -103,16 +104,19 @@ def isDrillable(obj, candidate):
if obj.isInside(lsp, 0, False) or obj.isInside(lep, 0, False):
drillable = False
# eliminate elliptical holes
elif abs(face.BoundBox.XLength - face.BoundBox.YLength) > 0.05:
elif not hasattr(face.Surface, "Radius"): #abs(face.BoundBox.XLength - face.BoundBox.YLength) > 0.05:
drillable = False
else:
drillable = True
else:
for edge in candidate.Edges:
if (isinstance(edge.Curve, Part.Circle)):
if abs(edge.BoundBox.XLength - edge.BoundBox.YLength) > 0.05:
if isinstance(edge.Curve, Part.Circle) and edge.isClosed():
PathLog.debug("candidate is a circle or ellipse")
if not hasattr(edge.Curve, "Radius"): #bbdiff > 0.05:
PathLog.debug("No radius. Ellipse.")
drillable = False
else:
PathLog.debug("Has Radius, Circle")
drillable = True
return drillable