Removed ToolController from all dressups and replaced with recursive search for the base op's ToolController.

This commit is contained in:
Markus Lampert
2018-01-21 20:06:11 -08:00
committed by wmayer
parent 69c1acd391
commit c3f03d3696
7 changed files with 36 additions and 35 deletions

View File

@@ -42,3 +42,13 @@ def hasEntryMethod(path):
return hasEntryMethod(path.Base)
return False
def baseOp(path):
'''baseOp(path) ... return the base operation underlying the given path'''
if 'Dressup' in path.Name:
return baseOp(path.Base)
return path
def toolController(path):
'''toolController(path) ... return the tool controller from the base op.'''
return baseOp(path).ToolController

View File

@@ -28,6 +28,7 @@ import FreeCADGui
import math
import Part
import Path
import PathScripts.PathDressup as PathDressup
import PathScripts.PathLog as PathLog
import PathScripts.PathUtil as PathUtil
import PathScripts.PathUtils as PathUtils
@@ -362,7 +363,6 @@ class ObjectDressup:
def __init__(self, obj, base):
# Tool Properties
obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool controller that will be used to calculate the path"))
obj.addProperty("App::PropertyLink", "Base", "Base", QtCore.QT_TRANSLATE_NOOP("Path_DressupDogbone", "The base path to modify"))
obj.addProperty("App::PropertyEnumeration", "Side", "Dressup", QtCore.QT_TRANSLATE_NOOP("Path_DressupDogbone", "The side of path to insert bones"))
obj.Side = [Side.Left, Side.Right]
@@ -803,7 +803,7 @@ class ObjectDressup:
obj.Side = side
self.toolRadius = 5
tc = obj.ToolController
tc = PathDressup.toolController(obj.Base)
if tc is None or tc.ToolNumber == 0:
self.toolRadius = 5
else:
@@ -1014,7 +1014,6 @@ def Create(base, name='DogboneDressup'):
ViewProviderDressup(obj.ViewObject)
obj.Base.ViewObject.Visibility = False
obj.ToolController = base.ToolController
dbo.setup(obj, True)
return obj

View File

@@ -24,6 +24,7 @@
import FreeCAD
import Part
import Path
import PathScripts.PathDressup as PathDressup
import PathScripts.PathLog as PathLog
import PathScripts.PathUtil as PathUtil
import PathScripts.PathUtils as PathUtils
@@ -788,10 +789,11 @@ class ObjectTagDressup:
lastCmd = Path.Command('G0', {'X': 0.0, 'Y': 0.0, 'Z': 0.0})
outCommands = []
horizFeed = obj.Base.ToolController.HorizFeed.Value
vertFeed = obj.Base.ToolController.VertFeed.Value
horizRapid = obj.Base.ToolController.HorizRapid.Value
vertRapid = obj.Base.ToolController.VertRapid.Value
tc = PathDressup.toolController(obj.Base)
horizFeed = tc.HorizFeed.Value
vertFeed = tc.VertFeed.Value
horizRapid = tc.HorizRapid.Value
vertRapid = tc.VertRapid.Value
for cmd in commands:
params = cmd.Parameters
@@ -936,7 +938,7 @@ class ObjectTagDressup:
PathLog.error(translate("Path_DressupTag", "Cannot insert holding tags for this path - please select a Profile path\n"))
return None
self.toolRadius = obj.Base.ToolController.Tool.Diameter / 2
self.toolRadius = PathDressup.toolController(obj.Base).Tool.Diameter / 2
self.pathData = pathData
if generate:
obj.Height = self.pathData.defaultTagHeight()

View File

@@ -55,7 +55,6 @@ class ObjectDressup:
def __init__(self, obj):
self.obj = obj
obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool controller that will be used to calculate the path"))
obj.addProperty("App::PropertyLink", "Base", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The base path to modify"))
obj.addProperty("App::PropertyBool", "LeadIn", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Calculate roll-on to path"))
obj.addProperty("App::PropertyBool", "LeadOut", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Calculate roll-off from path"))
@@ -85,9 +84,6 @@ class ObjectDressup:
obj.StyleOn = 'Arc'
obj.StyleOff = 'Arc'
obj.RadiusCenter = 'Radius'
if obj.Base:
if hasattr(obj.Base,"ToolController"):
obj.ToolController = obj.Base.ToolController
def execute(self, obj):
if not obj.Base:
@@ -127,9 +123,10 @@ class ObjectDressup:
global currLocation
results = []
# zdepth = currLocation["Z"]
horizFeed = obj.Base.ToolController.HorizFeed.Value
vertFeed = obj.Base.ToolController.VertFeed.Value
toolnummer = obj.Base.ToolController.ToolNumber
tc = PathDressup.toolController(obj.Base)
horizFeed = tc.HorizFeed.Value
vertFeed = tc.VertFeed.Value
toolnummer = tc.ToolNumber
# set the correct twist command
if self.getDirectionOfPath(obj) == 'left':
arcdir = "G3"
@@ -189,7 +186,7 @@ class ObjectDressup:
'''returns the Gcode of LeadOut.'''
global currLocation
results = []
horizFeed = obj.Base.ToolController.HorizFeed.Value
horizFeed = PathDressup.toolController(obj.Base).HorizFeed.Value
R = obj.Length.Value # Radius of roll or length
# set the correct twist command
if self.getDirectionOfPath(obj) == 'right':

View File

@@ -46,7 +46,6 @@ class ObjectDressup:
def __init__(self, obj):
self.obj = obj
obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool controller that will be used to calculate the path"))
obj.addProperty("App::PropertyLink", "Base", "Path", QtCore.QT_TRANSLATE_NOOP("Path_DressupRampEntry", "The base path to modify"))
obj.addProperty("App::PropertyAngle", "Angle", "Path", QtCore.QT_TRANSLATE_NOOP("Path_DressupRampEntry", "Angle of ramp."))
obj.addProperty("App::PropertyEnumeration", "Method", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Ramping Method"))
@@ -76,15 +75,6 @@ class ObjectDressup:
def setup(self, obj):
obj.Angle = 60
obj.Method = 2
toolLoad = obj.ToolController
if toolLoad is None or toolLoad.ToolNumber == 0:
PathLog.error(translate("No Tool Controller is selected. We need a tool to build a Path\n"))
return
else:
tool = toolLoad.Proxy.getTool(toolLoad)
if not tool:
PathLog.error(translate("No Tool found. We need a tool to build a Path.\n"))
return
def execute(self, obj):
@@ -520,16 +510,18 @@ class ObjectDressup:
outCommands = []
horizFeed = obj.ToolController.HorizFeed.Value
vertFeed = obj.ToolController.VertFeed.Value
tc = PathDressup.toolController(obj.Base)
horizFeed = tc.HorizFeed.Value
vertFeed = tc.VertFeed.Value
if obj.RampFeedRate == "Horizontal Feed Rate":
rampFeed = obj.ToolController.HorizFeed.Value
rampFeed = tc.HorizFeed.Value
elif obj.RampFeedRate == "Vertical Feed Rate":
rampFeed = obj.ToolController.VertFeed.Value
rampFeed = tc.VertFeed.Value
else:
rampFeed = obj.CustomFeedRate.Value
horizRapid = obj.ToolController.HorizRapid.Value
vertRapid = obj.ToolController.VertRapid.Value
horizRapid = tc.HorizRapid.Value
vertRapid = tc.VertRapid.Value
for cmd in commands:
params = cmd.Parameters
@@ -644,7 +636,6 @@ class CommandPathDressupRampEntry:
FreeCADGui.doCommand('PathScripts.PathDressupRampEntry.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(obj.Base.Name).Visibility = False')
FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)')
FreeCADGui.doCommand('dbo.setup(obj)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()

View File

@@ -24,6 +24,7 @@
import FreeCAD
import DraftGeomUtils
import Part
import PathScripts.PathDressup as PathDressup
import PathScripts.PathLog as PathLog
import PathScripts.PathUtils as PathUtils
import math
@@ -211,7 +212,7 @@ class ObjectDressup:
PathLog.track()
def toolRadius(self):
return self.obj.Base.ToolController.Tool.Diameter / 2.0
return PathDressup.toolController(self.obj.Base).Tool.Diameter / 2.0
def addTagsToDocuemnt(self):
for i, solid in enumerate(self.solids):

View File

@@ -58,4 +58,5 @@ if [ -z "$(which pylint)" ]; then
exit 1
fi
pylint ${ARGS} PathScripts/ PathTests/
#pylint ${ARGS} PathScripts/ PathTests/
pylint ${ARGS} PathScripts/