Addressed pylint warnings for PathDressups

This commit is contained in:
Markus Lampert
2019-06-30 15:24:12 -07:00
parent 35505b451a
commit 7219f6446d
4 changed files with 53 additions and 31 deletions

View File

@@ -32,7 +32,7 @@ from PySide import QtCore
if FreeCAD.GuiUp:
import FreeCADGui
"""Axis remapping Dressup object and FreeCAD command. This dressup remaps one axis of motion to another.
__doc__ = """Axis remapping Dressup object and FreeCAD command. This dressup remaps one axis of motion to another.
For example, you can re-map the Y axis to A to control a 4th axis rotary."""
# Qt translation handling
@@ -141,7 +141,7 @@ class ObjectDressup:
class ViewProviderDressup:
def __init__(self, vobj):
vobj.Proxy = self
self.obj = vobj.Object
def attach(self, vobj):
self.obj = vobj.Object
@@ -167,6 +167,7 @@ class ViewProviderDressup:
def onDelete(self, arg1=None, arg2=None):
'''this makes sure that the base operation is added back to the project and visible'''
# pylint: disable=unused-argument
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(arg1.Object)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
@@ -174,6 +175,7 @@ class ViewProviderDressup:
return True
class CommandPathDressup:
# pylint: disable=no-init
def GetResources(self):
return {'Pixmap': 'Path-Dressup',
@@ -185,7 +187,7 @@ class CommandPathDressup:
if FreeCAD.ActiveDocument is not None:
for o in FreeCAD.ActiveDocument.Objects:
if o.Name[:3] == "Job":
return True
return True
return False
def Activated(self):
@@ -213,7 +215,7 @@ class CommandPathDressup:
FreeCADGui.doCommand('obj.Base = base')
FreeCADGui.doCommand('obj.Radius = 45')
FreeCADGui.doCommand('job.Proxy.addOperation(obj, base)')
FreeCADGui.doCommand('PathScripts.PathDressupAxisMap.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('obj.ViewObject.Proxy = PathScripts.PathDressupAxisMap.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()

View File

@@ -30,7 +30,7 @@ import math
import DraftVecUtils as D
import PathScripts.PathUtils as PathUtils
"""Dragknife Dressup object and FreeCAD command"""
__doc__ = """Dragknife Dressup object and FreeCAD command"""
if FreeCAD.GuiUp:
import FreeCADGui
@@ -66,8 +66,6 @@ class ObjectDressup:
'''Determines whether its shorter to twist CW or CCW to align with the next move'''
# get the vector of the last move
global arccommands
if queue[1].Name in arccommands:
arcLoc = FreeCAD.Vector(queue[2].x + queue[1].I, queue[2].y + queue[1].J, currLocation['Z'])
radvector = arcLoc.sub(queue[1].Placement.Base) # .sub(arcLoc) # vector of chord from center to point
@@ -94,7 +92,6 @@ class ObjectDressup:
requires the previous command in order to calculate arcs correctly
if endpos = True, return the angle at the end of the segment.'''
global arccommands
if currCommand.Name in arccommands:
arcLoc = FreeCAD.Vector((prevCommand.x + currCommand.I), (prevCommand.y + currCommand.J), currentZ)
if endpos is True:
@@ -127,7 +124,7 @@ class ObjectDressup:
def arcExtension(self, obj, queue):
'''returns gcode for arc extension'''
global currLocation
global currLocation # pylint: disable=global-statement
results = []
offset = obj.offset
@@ -166,7 +163,7 @@ class ObjectDressup:
'''returns gcode to do an arc move toward an arc to perform
a corner action twist. Includes lifting and plungeing the knife'''
global currLocation
global currLocation # pylint: disable=global-statement
pivotheight = obj.pivotheight
offset = obj.offset
results = []
@@ -233,7 +230,7 @@ class ObjectDressup:
def lineExtension(self, obj, queue):
'''returns gcode for line extension'''
global currLocation
global currLocation # pylint: disable=global-statement
offset = float(obj.offset)
results = []
@@ -259,7 +256,7 @@ class ObjectDressup:
def lineTwist(self, obj, queue, lastXY, twistCW=False):
'''returns gcode to do an arc move toward a line to perform
a corner action twist. Includes lifting and plungeing the knife'''
global currLocation
global currLocation # pylint: disable=global-statement
pivotheight = obj.pivotheight
offset = obj.offset
@@ -310,7 +307,7 @@ class ObjectDressup:
def execute(self, obj):
newpath = []
global currLocation
global currLocation # pylint: disable=global-statement
if not obj.Base:
return
@@ -433,7 +430,7 @@ class ObjectDressup:
class ViewProviderDressup:
def __init__(self, vobj):
vobj.Proxy = self
self.Object = vobj.Object
def attach(self, vobj):
self.Object = vobj.Object
@@ -449,9 +446,11 @@ class ViewProviderDressup:
# FreeCADGui.ActiveDocument.getObject(obj.Base.Name).Visibility = False
def unsetEdit(self, vobj, mode=0):
# pylint: disable=unused-argument
return False
def setEdit(self, vobj, mode=0):
# pylint: disable=unused-argument
return True
def claimChildren(self):
@@ -461,9 +460,11 @@ class ViewProviderDressup:
return None
def __setstate__(self, state):
# pylint: disable=unused-argument
return None
def onDelete(self, arg1=None, arg2=None):
# pylint: disable=unused-argument
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(arg1.Object.Base)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
@@ -472,6 +473,7 @@ class ViewProviderDressup:
class CommandDressupDragknife:
# pylint: disable=no-init
def GetResources(self):
return {'Pixmap': 'Path-Dressup',
@@ -482,7 +484,7 @@ class CommandDressupDragknife:
if FreeCAD.ActiveDocument is not None:
for o in FreeCAD.ActiveDocument.Objects:
if o.Name[:3] == "Job":
return True
return True
return False
def Activated(self):
@@ -512,7 +514,7 @@ class CommandDressupDragknife:
FreeCADGui.doCommand('job = PathScripts.PathUtils.findParentJob(base)')
FreeCADGui.doCommand('obj.Base = base')
FreeCADGui.doCommand('job.Proxy.addOperation(obj, base)')
FreeCADGui.doCommand('PathScripts.PathDressupDragknife.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('obj.ViewObject.Proxy = PathScripts.PathDressupDragknife.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
FreeCADGui.doCommand('obj.filterangle = 20')
FreeCADGui.doCommand('obj.offset = 2')

View File

@@ -34,7 +34,7 @@ import math
from PySide import QtCore
"""LeadInOut Dressup MASHIN-CRC USE ROLL-ON ROLL-OFF to profile"""
__doc__ = """LeadInOut Dressup MASHIN-CRC USE ROLL-ON ROLL-OFF to profile"""
if FreeCAD.GuiUp:
import FreeCADGui
@@ -48,7 +48,6 @@ PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
movecommands = ['G1', 'G01', 'G2', 'G02', 'G3', 'G03']
rapidcommands = ['G0', 'G00']
arccommands = ['G2', 'G3', 'G02', 'G03']
global currLocation
currLocation = {}
@@ -70,10 +69,14 @@ class ObjectDressup:
obj.RadiusCenter = ["Radius", "Center"]
obj.Proxy = self
self.wire = None
self.rapids = None
def __getstate__(self):
return None
def __setstate__(self, state):
# pylint: disable=unused-argument
return None
def setup(self, obj):
@@ -122,7 +125,6 @@ class ObjectDressup:
def getLeadStart(self, obj, queue, action):
'''returns Lead In G-code.'''
global currLocation
results = []
# zdepth = currLocation["Z"]
op = PathDressup.baseOp(obj.Base)
@@ -171,10 +173,10 @@ class ObjectDressup:
extendcommand = Path.Command('G1', {"X": leadstart.x, "Y": leadstart.y, "Z": p1.z, "F": vertFeed})
results.append(extendcommand)
if obj.UseMachineCRC:
if self.getDirectionOfPath(obj) == 'right':
results.append(Path.Command('G42', {'D': toolnummer}))
else:
results.append(Path.Command('G41', {'D': toolnummer}))
if self.getDirectionOfPath(obj) == 'right':
results.append(Path.Command('G42', {'D': toolnummer}))
else:
results.append(Path.Command('G41', {'D': toolnummer}))
if obj.StyleOn == 'Arc':
arcmove = Path.Command(arcdir, {"X": p0.x, "Y": p0.y, "I": offsetvector.x, "J": offsetvector.y, "F": horizFeed}) # add G2/G3 move
results.append(arcmove)
@@ -187,7 +189,7 @@ class ObjectDressup:
def getLeadEnd(self, obj, queue, action):
'''returns the Gcode of LeadOut.'''
global currLocation
# pylint: disable=unused-argument
results = []
horizFeed = PathDressup.toolController(obj.Base).HorizFeed.Value
R = obj.Length.Value # Radius of roll or length
@@ -228,7 +230,7 @@ class ObjectDressup:
return results
def generateLeadInOutCurve(self, obj):
global currLocation
global currLocation # pylint: disable=global-statement
firstmove = Path.Command("G0", {"X": 0, "Y": 0, "Z": 0})
currLocation.update(firstmove.Parameters)
newpath = []
@@ -298,7 +300,7 @@ class ObjectDressup:
class ViewProviderDressup:
def __init__(self, vobj):
vobj.Proxy = self
self.obj = vobj.Object
def attach(self, vobj):
self.obj = vobj.Object
@@ -317,8 +319,9 @@ class ViewProviderDressup:
return [self.obj.Base]
def onDelete(self, arg1=None, arg2=None):
PathLog.debug("Deleting Dressup")
'''this makes sure that the base operation is added back to the project and visible'''
# pylint: disable=unused-argument
PathLog.debug("Deleting Dressup")
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(self.obj)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
@@ -329,10 +332,12 @@ class ViewProviderDressup:
return None
def __setstate__(self, state):
# pylint: disable=unused-argument
return None
class CommandPathDressupLeadInOut:
# pylint: disable=no-init
def GetResources(self):
return {'Pixmap': 'Path-Dressup',
@@ -370,7 +375,7 @@ class CommandPathDressupLeadInOut:
FreeCADGui.doCommand('job = PathScripts.PathUtils.findParentJob(base)')
FreeCADGui.doCommand('obj.Base = base')
FreeCADGui.doCommand('job.Proxy.addOperation(obj, base)')
FreeCADGui.doCommand('PathScripts.PathDressupLeadInOut.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('obj.ViewObject.Proxy = PathScripts.PathDressupLeadInOut.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
FreeCADGui.doCommand('dbo.setup(obj)')
FreeCAD.ActiveDocument.commitTransaction()

View File

@@ -60,6 +60,15 @@ class ObjectDressup:
obj.Proxy = self
self.setEditorProperties(obj)
# initialized later
self.wire = None
self.angle = None
self.rapids = None
self.method = None
self.outedges = None
self.ignoreAboveEnabled = None
self.ignoreAbove = None
def __getstate__(self):
return None
@@ -366,6 +375,7 @@ class ObjectDressup:
curPoint = p0 # start from the upper point of plunge
done = False
goingForward = True
i = 0
while not done:
for i, redge in enumerate(rampedges):
if redge.Length >= rampremaining:
@@ -432,6 +442,7 @@ class ObjectDressup:
curPoint = p0 # start from the upper point of plunge
done = False
i = 0
while not done:
for i, redge in enumerate(rampedges):
if redge.Length >= rampremaining:
@@ -621,7 +632,7 @@ class ObjectDressup:
class ViewProviderDressup:
def __init__(self, vobj):
vobj.Proxy = self
self.obj = vobj.Object
def attach(self, vobj):
self.obj = vobj.Object
@@ -640,8 +651,9 @@ class ViewProviderDressup:
return [self.obj.Base]
def onDelete(self, arg1=None, arg2=None):
PathLog.debug("Deleting Dressup")
'''this makes sure that the base operation is added back to the project and visible'''
# pylint: disable=unused-argument
PathLog.debug("Deleting Dressup")
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(self.obj)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
@@ -656,6 +668,7 @@ class ViewProviderDressup:
class CommandPathDressupRampEntry:
# pylint: disable=no-init
def GetResources(self):
return {'Pixmap': 'Path-Dressup',
@@ -693,7 +706,7 @@ class CommandPathDressupRampEntry:
FreeCADGui.doCommand('job = PathScripts.PathUtils.findParentJob(base)')
FreeCADGui.doCommand('obj.Base = base')
FreeCADGui.doCommand('job.Proxy.addOperation(obj, base)')
FreeCADGui.doCommand('PathScripts.PathDressupRampEntry.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('obj.ViewObject.Proxy = PathScripts.PathDressupRampEntry.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
FreeCADGui.doCommand('dbo.setup(obj)')
FreeCAD.ActiveDocument.commitTransaction()