Path: implement jointype for contour and profile fix #3116

Not implemented in the task panel.  Settings are only available in the property pane.
This commit is contained in:
sliptonic
2017-07-08 11:41:41 -05:00
committed by Yorik van Havre
parent 75121febf0
commit 9a15fed386
2 changed files with 35 additions and 2 deletions

View File

@@ -36,7 +36,7 @@ from PathScripts.PathUtils import depth_params
FreeCAD.setLogLevel('Path.Area', 0)
if False:
if True:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
@@ -85,6 +85,11 @@ class ObjectContour:
obj.addProperty("App::PropertyDistance", "OffsetExtra", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property", "Extra value to stay away from final Contour- good for roughing toolpath"))
obj.addProperty("App::PropertyEnumeration", "JoinType", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property", "Controls how tool moves around corners. Default=Round"))
obj.JoinType = ['Round', 'Square', 'Miter'] # this is the direction that the Contour runs
obj.addProperty("App::PropertyFloat", "MiterLimit", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property", "Maximum distance before a miter join is truncated"))
obj.setEditorMode('MiterLimit', 2)
# Debug Parameters
obj.addProperty("App::PropertyString", "AreaParams", "Path")
obj.setEditorMode('AreaParams', 2) # hide
@@ -104,6 +109,10 @@ class ObjectContour:
if prop in ['AreaParams', 'PathParams', 'removalshape']:
obj.setEditorMode(prop, 2)
obj.setEditorMode('MiterLimit', 2)
if obj.JoinType == 'Miter':
obj.setEditorMode('MiterLimit', 0)
def __getstate__(self):
PathLog.track()
return None
@@ -148,6 +157,12 @@ class ObjectContour:
else:
profileparams['Offset'] = self.radius+obj.OffsetExtra.Value
jointype = ['Round', 'Square', 'Miter']
profileparams['JoinType'] = jointype.index(obj.JoinType)
if obj.JoinType == 'Miter':
profileparams['MiterLimit'] = obj.MiterLimit
heights = [i for i in self.depthparams]
PathLog.debug('depths: {}'.format(heights))
profile.setParams(**profileparams)
@@ -370,6 +385,8 @@ class CommandPathContour:
FreeCADGui.doCommand('obj.OffsetExtra = 0.0')
FreeCADGui.doCommand('obj.Direction = "CW"')
FreeCADGui.doCommand('obj.UseComp = True')
FreeCADGui.doCommand('obj.JoinType = "Round"')
FreeCADGui.doCommand('obj.MiterLimit =' + str(0.1))
FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
FreeCADGui.doCommand('PathScripts.PathContour.ObjectContour.setDepths(obj.Proxy, obj)')

View File

@@ -41,6 +41,7 @@ if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore, QtGui
# Qt tanslation handling
def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
@@ -84,6 +85,9 @@ class ObjectProfile:
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.addProperty("App::PropertyEnumeration", "JoinType", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Controls how tool moves around corners. Default=Round"))
obj.JoinType = ['Round', 'Square', 'Miter'] # this is the direction that the Contour runs
obj.addProperty("App::PropertyFloat", "MiterLimit", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Maximum distance before a miter join is truncated"))
# Debug Parameters
obj.addProperty("App::PropertyString", "AreaParams", "Path")
@@ -113,6 +117,10 @@ class ObjectProfile:
if prop in ['AreaParams', 'PathParams', 'removalshape']:
obj.setEditorMode(prop, 2)
obj.setEditorMode('MiterLimit', 2)
if obj.JoinType == 'Miter':
obj.setEditorMode('MiterLimit', 0)
def addprofilebase(self, obj, ss, sub=""):
baselist = obj.Base
if len(baselist) == 0: # When adding the first base object, guess at heights
@@ -176,6 +184,12 @@ class ObjectProfile:
profileparams['Offset'] = offsetval
jointype = ['Round', 'Square', 'Miter']
profileparams['JoinType'] = jointype.index(obj.JoinType)
if obj.JoinType == 'Miter':
profileparams['MiterLimit'] = obj.MiterLimit
profile.setParams(**profileparams)
obj.AreaParams = str(profile.getParams())
@@ -437,12 +451,14 @@ class CommandPathProfile:
FreeCADGui.doCommand('obj.UseComp = True')
FreeCADGui.doCommand('obj.processHoles = False')
FreeCADGui.doCommand('obj.processPerimeter = True')
FreeCADGui.doCommand('obj.JoinType = "Round"')
FreeCADGui.doCommand('obj.MiterLimit =' + str(0.1))
FreeCADGui.doCommand('obj.ViewObject.Proxy.deleteOnReject = True')
FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)')
FreeCAD.ActiveDocument.commitTransaction()
#FreeCAD.ActiveDocument.recompute()
FreeCADGui.doCommand('obj.ViewObject.startEditing()')