Path: normalize proxy stratements
remove bare exceptions
This commit is contained in:
@@ -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"]
|
||||
@@ -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,
|
||||
@@ -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}))
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import ArchPanel
|
||||
# import ArchPanel
|
||||
import FreeCAD
|
||||
import Path
|
||||
import PathScripts.PathCircularHoleBase as PathCircularHoleBase
|
||||
@@ -32,7 +32,7 @@ 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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
# ***************************************************************************
|
||||
|
||||
import FreeCAD
|
||||
import Part
|
||||
import Path
|
||||
|
||||
import PathScripts.PathCircularHoleBase as PathCircularHoleBase
|
||||
@@ -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
|
||||
|
||||
@@ -227,7 +227,7 @@ class ObjectJob:
|
||||
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")
|
||||
|
||||
@@ -328,7 +328,7 @@ class StockFromBaseBoundBoxEdit(StockEdit):
|
||||
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']):
|
||||
@@ -419,7 +419,7 @@ class StockCreateBoxEdit(StockEdit):
|
||||
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):
|
||||
@@ -453,7 +453,7 @@ class StockCreateCylinderEdit(StockEdit):
|
||||
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):
|
||||
@@ -623,7 +623,7 @@ class TaskPanel:
|
||||
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()
|
||||
@@ -829,7 +829,7 @@ class TaskPanel:
|
||||
elif 'Number' == prop:
|
||||
try:
|
||||
tc.ToolNumber = int(item.text())
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
item.setText("%d" % tc.ToolNumber)
|
||||
elif 'Spindle' == prop:
|
||||
@@ -841,7 +841,7 @@ class TaskPanel:
|
||||
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:
|
||||
@@ -853,14 +853,14 @@ class TaskPanel:
|
||||
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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -234,7 +234,7 @@ class CommandPathPost:
|
||||
elif hasattr(sel, "Path"):
|
||||
try:
|
||||
job = PathUtils.findParentJob(sel)
|
||||
except:
|
||||
except Exception:
|
||||
job = None
|
||||
else:
|
||||
job = None
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -28,7 +28,7 @@ import ArchPanel
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
@@ -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:
|
||||
@@ -103,7 +103,7 @@ class PROFILEGate:
|
||||
profileable = False
|
||||
try:
|
||||
obj = obj.Shape
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
if obj.ShapeType == 'Edge':
|
||||
@@ -138,7 +138,7 @@ class POCKETGate:
|
||||
pocketable = False
|
||||
try:
|
||||
obj = obj.Shape
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
if obj.ShapeType == 'Edge':
|
||||
@@ -163,7 +163,7 @@ class ADAPTIVEGate:
|
||||
adaptive = True
|
||||
try:
|
||||
obj = obj.Shape
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
return adaptive
|
||||
|
||||
@@ -259,13 +259,13 @@ class SetupSheet:
|
||||
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):
|
||||
|
||||
@@ -47,7 +47,7 @@ class CommandPathSimpleCopy:
|
||||
try:
|
||||
obj = FreeCADGui.Selection.getSelectionEx()[0].Object
|
||||
return isinstance(obj.Proxy, PathScripts.PathOp.ObjectOp)
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def Activated(self):
|
||||
|
||||
@@ -119,7 +119,7 @@ class PathSimulation:
|
||||
self.operation = self.activeOps[itool]
|
||||
try:
|
||||
self.tool = PathDressup.toolController(self.operation).Tool
|
||||
except:
|
||||
except Exception:
|
||||
self.tool = None
|
||||
|
||||
# if hasattr(self.operation, "ToolController"):
|
||||
@@ -214,7 +214,7 @@ class PathSimulation:
|
||||
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:
|
||||
@@ -345,7 +345,7 @@ class PathSimulation:
|
||||
try:
|
||||
startDir.normalize()
|
||||
endDir.normalize()
|
||||
except:
|
||||
except Exception:
|
||||
return (None, endPos)
|
||||
# height = self.height
|
||||
|
||||
@@ -367,7 +367,7 @@ class PathSimulation:
|
||||
pathWire = Part.Wire(toolPath)
|
||||
try:
|
||||
pathShell = pathWire.makePipeShell([fullProf], False, True)
|
||||
except:
|
||||
except Exception:
|
||||
if self.debug:
|
||||
Part.show(pathWire)
|
||||
Part.show(fullProf)
|
||||
|
||||
@@ -227,7 +227,7 @@ def CreateFromBase(job, neg=None, pos=None, placement=None):
|
||||
PathLog.track(job.Label, neg, pos, placement)
|
||||
base = job.Model if job else None
|
||||
obj = FreeCAD.ActiveDocument.addObject('Part::FeaturePython', 'Stock')
|
||||
proxy = StockFromBase(obj, base)
|
||||
obj.Proxy = StockFromBase(obj, base)
|
||||
|
||||
if neg:
|
||||
obj.ExtXneg = neg.x
|
||||
@@ -243,14 +243,14 @@ def CreateFromBase(job, neg=None, pos=None, placement=None):
|
||||
obj.Placement = placement
|
||||
|
||||
SetupStockObject(obj, StockType.FromBase)
|
||||
proxy.execute(obj)
|
||||
obj.Proxy.execute(obj)
|
||||
obj.purgeTouched()
|
||||
return obj
|
||||
|
||||
def CreateBox(job, extent=None, placement=None):
|
||||
base = job.Model if job else None
|
||||
obj = FreeCAD.ActiveDocument.addObject('Part::FeaturePython', 'Stock')
|
||||
proxy = StockCreateBox(obj)
|
||||
obj.Proxy = StockCreateBox(obj)
|
||||
|
||||
if extent:
|
||||
obj.Length = extent.x
|
||||
@@ -275,7 +275,7 @@ def CreateBox(job, extent=None, placement=None):
|
||||
def CreateCylinder(job, radius=None, height=None, placement=None):
|
||||
base = job.Model if job else None
|
||||
obj = FreeCAD.ActiveDocument.addObject('Part::FeaturePython', 'Stock')
|
||||
proxy = StockCreateCylinder(obj)
|
||||
obj.Proxy = StockCreateCylinder(obj)
|
||||
|
||||
if radius:
|
||||
obj.Radius = radius
|
||||
|
||||
@@ -1917,5 +1917,5 @@ def Create(name, obj=None):
|
||||
'''Create(name) ... Creates and returns a Surface operation.'''
|
||||
if obj is None:
|
||||
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
|
||||
proxy = ObjectSurface(obj, name)
|
||||
obj.Proxy = ObjectSurface(obj, name)
|
||||
return obj
|
||||
|
||||
@@ -406,7 +406,7 @@ def getToolControllers(obj):
|
||||
'''returns all the tool controllers'''
|
||||
try:
|
||||
job = findParentJob(obj)
|
||||
except:
|
||||
except Exception:
|
||||
job = None
|
||||
|
||||
if job:
|
||||
|
||||
Reference in New Issue
Block a user