Skip to content

Commit

Permalink
Path: normalize proxy stratements
Browse files Browse the repository at this point in the history
remove bare exceptions
  • Loading branch information
sliptonic committed Jun 21, 2019
1 parent 4a0be9d commit 4a984de
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 51 deletions.
10 changes: 5 additions & 5 deletions src/Mod/Path/PathScripts/PathAdaptive.py
Expand Up @@ -94,7 +94,7 @@ def GenerateGCode(op,obj,adaptiveResults, helixDiameter):
if len(adaptiveResults) == 0 or len(adaptiveResults[0]["AdaptivePaths"]) == 0:
return

minLiftDistance = op.tool.Diameter
# minLiftDistance = op.tool.Diameter
helixRadius = 0
for region in adaptiveResults:
p1 = region["HelixCenterPoint"]
Expand Down Expand Up @@ -126,7 +126,7 @@ def GenerateGCode(op,obj,adaptiveResults, helixDiameter):
finish_step = obj.FinishDepth.Value if hasattr(obj, "FinishDepth") else 0.0
if finish_step > stepDown:
finish_step = stepDown

depth_params = PathUtils.depth_params(
clearance_height=obj.ClearanceHeight.Value,
safe_height=obj.SafeHeight.Value,
Expand Down Expand Up @@ -213,13 +213,13 @@ def GenerateGCode(op,obj,adaptiveResults, helixDiameter):

x = region["HelixCenterPoint"][0] + r
y = region["HelixCenterPoint"][1]

curDep = passStartDepth
while curDep > (passEndDepth + depthPerOneCircle):
op.commandlist.append(Path.Command("G2", { "X": x - (2*r), "Y": y, "Z": curDep - (depthPerOneCircle/2), "I": -r, "F": op.horizFeed}))
op.commandlist.append(Path.Command("G2", { "X": x, "Y": y, "Z": curDep - depthPerOneCircle, "I": r, "F": op.horizFeed}))
curDep = curDep - depthPerOneCircle

lastStep = curDep - passEndDepth
if lastStep > (depthPerOneCircle/2):
op.commandlist.append(Path.Command("G2", { "X": x - (2*r), "Y": y, "Z": curDep - (lastStep/2), "I": -r, "F": op.horizFeed}))
Expand Down Expand Up @@ -252,7 +252,7 @@ def GenerateGCode(op,obj,adaptiveResults, helixDiameter):
x = pt[0]
y = pt[1]

dist = math.sqrt((x-lx)*(x-lx) + (y-ly)*(y-ly))
# dist = math.sqrt((x-lx)*(x-lx) + (y-ly)*(y-ly))

if motionType == area.AdaptiveMotionType.Cutting:
z = passEndDepth
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathDeburr.py
Expand Up @@ -147,5 +147,5 @@ def Create(name, obj=None):
'''Create(name) ... Creates and returns a Deburr operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
proxy = ObjectDeburr(obj, name)
obj.Proxy = ObjectDeburr(obj, name)
return obj
4 changes: 2 additions & 2 deletions src/Mod/Path/PathScripts/PathDrilling.py
Expand Up @@ -24,15 +24,15 @@

from __future__ import print_function

import ArchPanel
# import ArchPanel
import FreeCAD
import Path
import PathScripts.PathCircularHoleBase as PathCircularHoleBase
import PathScripts.PathLog as PathLog
import PathScripts.PathOp as PathOp
import PathScripts.PathUtils as PathUtils

from PathScripts.PathUtils import fmt, waiting_effects
# from PathScripts.PathUtils import waiting_effects
from PySide import QtCore

__title__ = "Path Drilling Operation"
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathEngrave.py
Expand Up @@ -142,5 +142,5 @@ def Create(name, obj=None):
'''Create(name) ... Creates and returns an Engrave operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
proxy = ObjectEngrave(obj, name)
obj.Proxy = ObjectEngrave(obj, name)
return obj
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathGuiInit.py
Expand Up @@ -69,7 +69,7 @@ def Startup():
try:
import ocl
from PathScripts import PathSurfaceGui
except:
except ImportError:
import FreeCAD
FreeCAD.Console.PrintError("OpenCamLib is not working!\n")
pass
Expand Down
5 changes: 2 additions & 3 deletions src/Mod/Path/PathScripts/PathHelix.py
Expand Up @@ -23,7 +23,6 @@
# ***************************************************************************

import FreeCAD
import Part
import Path

import PathScripts.PathCircularHoleBase as PathCircularHoleBase
Expand Down Expand Up @@ -203,7 +202,7 @@ def Create(name, obj = None):
'''Create(name) ... Creates and returns a Helix operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
proxy = ObjectHelix(obj, name)
obj.Proxy = ObjectHelix(obj, name)
if obj.Proxy:
proxy.findAllHoles(obj)
obj.Proxy.findAllHoles(obj)
return obj
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathJob.py
Expand Up @@ -227,7 +227,7 @@ def fixupOperations(self, obj):
if obj.Operations.ViewObject:
try:
obj.Operations.ViewObject.DisplayMode
except:
except Exception:
name = obj.Operations.Name
label = obj.Operations.Label
ops = FreeCAD.ActiveDocument.addObject("Path::FeatureCompoundPython", "Operations")
Expand Down
16 changes: 8 additions & 8 deletions src/Mod/Path/PathScripts/PathJobGui.py
Expand Up @@ -328,7 +328,7 @@ def getFieldsStock(self, stock, fields=['xneg', 'xpos', 'yneg', 'ypos', 'zneg',
stock.ExtZneg = FreeCAD.Units.Quantity(self.form.stockExtZneg.text())
if 'zpos' in fields:
stock.ExtZpos = FreeCAD.Units.Quantity(self.form.stockExtZpos.text())
except:
except Exception:
pass

def getFields(self, obj, fields=['xneg', 'xpos', 'yneg', 'ypos', 'zneg', 'zpos']):
Expand Down Expand Up @@ -419,7 +419,7 @@ def getFields(self, obj, fields=['length', 'widht', 'height']):
obj.Stock.Height = FreeCAD.Units.Quantity(self.form.stockBoxHeight.text())
else:
PathLog.error(translate('PathJob', 'Stock not a box!'))
except:
except Exception:
pass

def setFields(self, obj):
Expand Down Expand Up @@ -453,7 +453,7 @@ def getFields(self, obj, fields=['radius', 'height']):
obj.Stock.Height = FreeCAD.Units.Quantity(self.form.stockCylinderHeight.text())
else:
PathLog.error(translate('PathJob', 'Stock not a cylinder!'))
except:
except Exception:
pass

def setFields(self, obj):
Expand Down Expand Up @@ -623,7 +623,7 @@ def getFields(self):
if self.form.wcslist.item(i).checkState() == QtCore.Qt.CheckState.Checked:
flist.append(self.form.wcslist.item(i).text())
self.obj.Fixtures = flist
except:
except Exception:
FreeCAD.Console.PrintWarning("The Job was created without fixture support. Please delete and recreate the job\r\n")

self.updateTooltips()
Expand Down Expand Up @@ -829,7 +829,7 @@ def toolControllerChanged(self, item):
elif 'Number' == prop:
try:
tc.ToolNumber = int(item.text())
except:
except Exception:
pass
item.setText("%d" % tc.ToolNumber)
elif 'Spindle' == prop:
Expand All @@ -841,7 +841,7 @@ def toolControllerChanged(self, item):
speed = -speed
tc.SpindleDir = rot
tc.SpindleSpeed = speed
except:
except Exception:
pass
item.setText("%s%g" % ('+' if tc.SpindleDir == 'Forward' else '-', tc.SpindleSpeed))
elif 'HorizFeed' == prop or 'VertFeed' == prop:
Expand All @@ -853,14 +853,14 @@ def toolControllerChanged(self, item):
elif FreeCAD.Units.Unit() == val.Unit:
val = FreeCAD.Units.Quantity(item.text() + vUnit)
setattr(tc, prop, val)
except:
except Exception:
pass
item.setText("%g" % getattr(tc, prop).getValueAs(vUnit))
else:
try:
val = FreeCAD.Units.Quantity(item.text())
setattr(tc, prop, val)
except:
except Exception:
pass
item.setText("%g" % getattr(tc, prop).Value)

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathMillFace.py
Expand Up @@ -146,5 +146,5 @@ def Create(name, obj = None):
'''Create(name) ... Creates and returns a Mill Facing operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
proxy = ObjectFace(obj, name)
obj.Proxy = ObjectFace(obj, name)
return obj
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathOpTools.py
Expand Up @@ -203,7 +203,7 @@ def offsetWire(wire, base, offset, forward):
PathLog.track('closed - inside')
try:
owire = wire.makeOffset2D(-offset)
except:
except Exception:
# most likely offsetting didn't work because the wire is a hole
# and the offset is too big - making the hole vanish
return None
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Path/PathScripts/PathPocket.py
Expand Up @@ -24,12 +24,12 @@

import FreeCAD
import Part
import PathScripts.PathGeom as PathGeom
# import PathScripts.PathGeom as PathGeom
import PathScripts.PathLog as PathLog
import PathScripts.PathOp as PathOp
import PathScripts.PathPocketBase as PathPocketBase
import PathScripts.PathUtils as PathUtils
import sys
# import sys

from PySide import QtCore

Expand Down Expand Up @@ -100,5 +100,5 @@ def Create(name, obj = None):
'''Create(name) ... Creates and returns a Pocket operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
proxy = ObjectPocket(obj, name)
obj.Proxy = ObjectPocket(obj, name)
return obj
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathPost.py
Expand Up @@ -234,7 +234,7 @@ def Activated(self):
elif hasattr(sel, "Path"):
try:
job = PathUtils.findParentJob(sel)
except:
except Exception:
job = None
else:
job = None
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathPreferences.py
Expand Up @@ -167,6 +167,6 @@ def experimentalFeaturesEnabled():
try:
import ocl
return preferences().GetBool(EnableExperimentalFeatures, False)
except:
except ImportError:
FreeCAD.Console.PrintError("OpenCamLib is not working!\n")
return False
4 changes: 2 additions & 2 deletions src/Mod/Path/PathScripts/PathProfileContour.py
Expand Up @@ -28,7 +28,7 @@
import FreeCAD
import Part
import Path
import PathScripts.PathAreaOp as PathAreaOp
# import PathScripts.PathAreaOp as PathAreaOp
import PathScripts.PathProfileBase as PathProfileBase
import PathScripts.PathLog as PathLog

Expand Down Expand Up @@ -116,6 +116,6 @@ def Create(name, obj = None):
'''Create(name) ... Creates and returns a Contour operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
proxy = ObjectContour(obj, name)
obj.Proxy = ObjectContour(obj, name)
return obj

4 changes: 2 additions & 2 deletions src/Mod/Path/PathScripts/PathProfileEdges.py
Expand Up @@ -25,7 +25,7 @@
import FreeCAD
import Part
import Path
import PathScripts.PathAreaOp as PathAreaOp
# import PathScripts.PathAreaOp as PathAreaOp
import PathScripts.PathLog as PathLog
import PathScripts.PathOp as PathOp
import PathScripts.PathProfileBase as PathProfileBase
Expand Down Expand Up @@ -104,5 +104,5 @@ def Create(name, obj = None):
'''Create(name) ... Creates and returns a Profile based on edges operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
proxy = ObjectProfile(obj, name)
obj.Proxy = ObjectProfile(obj, name)
return obj
10 changes: 5 additions & 5 deletions src/Mod/Path/PathScripts/PathSelection.py
Expand Up @@ -48,7 +48,7 @@ class ENGRAVEGate:
def allow(self, doc, obj, sub):
try:
shape = obj.Shape
except:
except Exception:
return False

if math.fabs(shape.Volume) < 1e-9 and len(shape.Wires) > 0:
Expand All @@ -68,7 +68,7 @@ class CHAMFERGate:
def allow(self, doc, obj, sub):
try:
shape = obj.Shape
except:
except Exception:
return False

if math.fabs(shape.Volume) < 1e-9 and len(shape.Wires) > 0:
Expand Down Expand Up @@ -103,7 +103,7 @@ def allow(self, doc, obj, sub):
profileable = False
try:
obj = obj.Shape
except:
except Exception:
return False

if obj.ShapeType == 'Edge':
Expand Down Expand Up @@ -138,7 +138,7 @@ def allow(self, doc, obj, sub):
pocketable = False
try:
obj = obj.Shape
except:
except Exception:
return False

if obj.ShapeType == 'Edge':
Expand All @@ -163,7 +163,7 @@ def allow(self, doc, obj, sub):
adaptive = True
try:
obj = obj.Shape
except:
except Exception:
return False

return adaptive
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Path/PathScripts/PathSetupSheet.py
Expand Up @@ -259,13 +259,13 @@ def setOperationProperties(self, obj, opName):
propName = OpPropertyName(opName, prop)
if hasattr(self.obj, propName):
setattr(obj, prop, getattr(self.obj, propName))
except Exception as exc:
except Exception:
PathLog.info("SetupSheet has no support for {}".format(opName))
#traceback.print_exc(exc)

def Create(name = 'SetupSheet'):
obj = FreeCAD.ActiveDocument.addObject('App::FeaturePython', name)
proxy = SetupSheet(obj)
obj.Proxy = SetupSheet(obj)
return obj

class _RegisteredOp(object):
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathSimpleCopy.py
Expand Up @@ -47,7 +47,7 @@ def IsActive(self):
try:
obj = FreeCADGui.Selection.getSelectionEx()[0].Object
return isinstance(obj.Proxy, PathScripts.PathOp.ObjectOp)
except:
except Exception:
return False

def Activated(self):
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Path/PathScripts/PathSimulatorGui.py
Expand Up @@ -119,7 +119,7 @@ def SetupOperation(self, itool):
self.operation = self.activeOps[itool]
try:
self.tool = PathDressup.toolController(self.operation).Tool
except:
except Exception:
self.tool = None

# if hasattr(self.operation, "ToolController"):
Expand Down Expand Up @@ -214,7 +214,7 @@ def PerformCutBoolean(self):
try:
if newStock.isValid():
self.stock = newStock.removeSplitter()
except:
except Exception:
if self.debug:
print("invalid cut at cmd #{}".format(self.icmd))
if not self.disableAnim:
Expand Down Expand Up @@ -345,7 +345,7 @@ def GetPathSolid(self, tool, cmd, pos):
try:
startDir.normalize()
endDir.normalize()
except:
except Exception:
return (None, endPos)
# height = self.height

Expand All @@ -367,7 +367,7 @@ def GetPathSolid(self, tool, cmd, pos):
pathWire = Part.Wire(toolPath)
try:
pathShell = pathWire.makePipeShell([fullProf], False, True)
except:
except Exception:
if self.debug:
Part.show(pathWire)
Part.show(fullProf)
Expand Down

0 comments on commit 4a984de

Please sign in to comment.