Skip to content

Commit

Permalink
make deburr ignore non-vertical faces
Browse files Browse the repository at this point in the history
fixes #4327
  • Loading branch information
sliptonic committed Oct 9, 2020
1 parent b5f37f0 commit ed61873
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
34 changes: 29 additions & 5 deletions src/Mod/Path/PathScripts/PathDeburrGui.py
Expand Up @@ -28,7 +28,7 @@
import PathScripts.PathGui as PathGui
import PathScripts.PathLog as PathLog
import PathScripts.PathOpGui as PathOpGui

import Part
from PySide import QtCore, QtGui

__title__ = "Path Deburr Operation UI"
Expand All @@ -44,19 +44,39 @@
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())


def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)


class TaskPanelBaseGeometryPage(PathOpGui.TaskPanelBaseGeometryPage):
'''Enhanced base geometry page to also allow special base objects.'''

def super(self):
return super(TaskPanelBaseGeometryPage, self)

def addBaseGeometry(self, selection):
for sel in selection:
if sel.HasSubObjects:
# selectively add some elements of the drawing to the Base
for sub in sel.SubObjects:
if isinstance(sub, Part.Face):
if sub.normalAt(0, 0) != FreeCAD.Vector(0, 0, 1):
PathLog.info(translate("Path", "Ignoring non-vertical Face"))
return

self.super().addBaseGeometry(selection)


class TaskPanelOpPage(PathOpGui.TaskPanelPage):
'''Page controller class for the Deburr operation.'''

def getForm(self):
return FreeCADGui.PySideUic.loadUi(":/panels/PageOpDeburrEdit.ui")

def initPage(self, obj):
self.opImagePath = "{}Mod/Path/Images/Ops/{}".format(FreeCAD.getHomePath(), 'chamfer.svg') # pylint: disable=attribute-defined-outside-init
self.opImage = QtGui.QPixmap(self.opImagePath) # pylint: disable=attribute-defined-outside-init
self.opImagePath = "{}Mod/Path/Images/Ops/{}".format(FreeCAD.getHomePath(), 'chamfer.svg') # pylint: disable=attribute-defined-outside-init
self.opImage = QtGui.QPixmap(self.opImagePath) # pylint: disable=attribute-defined-outside-init
self.form.opImage.setPixmap(self.opImage)
iconMiter = QtGui.QIcon(':/icons/edge-join-miter-not.svg')
iconMiter.addFile(':/icons/edge-join-miter.svg', state=QtGui.QIcon.On)
Expand All @@ -72,7 +92,7 @@ def getFields(self, obj):
obj.Join = 'Round'
elif self.form.joinMiter.isChecked():
obj.Join = 'Miter'

if obj.Direction != str(self.form.direction.currentText()):
obj.Direction = str(self.form.direction.currentText())

Expand Down Expand Up @@ -109,6 +129,11 @@ def registerSignalHandlers(self, obj):
self.form.value_W.editingFinished.connect(self.updateWidth)
self.form.value_h.editingFinished.connect(self.updateExtraDepth)

def taskPanelBaseGeometryPage(self, obj, features):
'''taskPanelBaseGeometryPage(obj, features) ... return page for adding base geometries.'''
print(features)
return TaskPanelBaseGeometryPage(obj, features)


Command = PathOpGui.SetupOperation('Deburr',
PathDeburr.Create,
Expand All @@ -119,4 +144,3 @@ def registerSignalHandlers(self, obj):
PathDeburr.SetupProperties)

FreeCAD.Console.PrintLog("Loading PathDeburrGui... done\n")

12 changes: 9 additions & 3 deletions src/Mod/Path/PathScripts/PathSelection.py
Expand Up @@ -107,15 +107,21 @@ def allow(self, doc, obj, sub): # pylint: disable=unused-argument
if math.fabs(shape.Volume) < 1e-9 and len(shape.Wires) > 0:
return True

if 'Edge' == shape.ShapeType or 'Face' == shape.ShapeType:
if shape.ShapeType == 'Edge':
return True

if (shape.ShapeType == 'Face'
and shape.normalAt(0,0) == FreeCAD.Vector(0,0,1)):
return True

if sub:
subShape = shape.getElement(sub)
if 'Edge' == subShape.ShapeType or 'Face' == subShape.ShapeType:
if subShape.ShapeType == 'Edge':
return True
elif (subShape.ShapeType == 'Face'
and subShape.normalAt(0,0) == FreeCAD.Vector(0,0,1)):
return True

print(shape.ShapeType)
return False


Expand Down

0 comments on commit ed61873

Please sign in to comment.