add try except

This commit is contained in:
Thomas-Alexandre Moreau 2025-01-30 18:14:44 +01:00
parent e6d9eae3a1
commit 54676b04a6

View file

@ -44,7 +44,7 @@ class WindowDialog():
isSVGFull = False isSVGFull = False
YBlockCounter = 0 YBlockCounter = 0
SVGNameCounter = 1 SVGNameCounter = 1
maxY = 0 maxY = 0.0
index = 0 index = 0
listSize = len(copy_sketchList) listSize = len(copy_sketchList)
@ -68,10 +68,11 @@ class WindowDialog():
__obj__[0].Placement=App.Placement(App.Vector(0,0,0), App.Rotation(App.Vector(1,0,0),0), App.Vector(0,0,0)) __obj__[0].Placement=App.Placement(App.Vector(0,0,0), App.Rotation(App.Vector(1,0,0),0), App.Vector(0,0,0))
if currentX == 0.0: if currentX == 0.0:
__obj__[0].Placement.Base = FreeCAD.Vector(currentX, currentY, 0.0) __obj__[0].Placement.Base = FreeCAD.Vector(currentX, currentY, 0.0)
currentX += boundingBox.XLength
else: else:
__obj__[0].Placement.Base = FreeCAD.Vector(currentX + spacing, currentY, 0.0) __obj__[0].Placement.Base = FreeCAD.Vector(currentX + spacing, currentY, 0.0)
currentX += boundingBox.XLength + spacing
currentX += boundingBox.XLength
copy_sketchList.pop(index) copy_sketchList.pop(index)
listSize = len(copy_sketchList) listSize = len(copy_sketchList)
App.activeDocument().recompute() App.activeDocument().recompute()
@ -79,6 +80,7 @@ class WindowDialog():
currentY += maxY + spacing currentY += maxY + spacing
maxY = 0.0
index = 0 index = 0
listSize = len(copy_sketchList) listSize = len(copy_sketchList)
App.activeDocument().recompute() App.activeDocument().recompute()
@ -122,7 +124,7 @@ class WindowDialog():
if hasattr(child, 'Dir'): if hasattr(child, 'Dir'):
sv0 = Draft.make_shape2dview(selectedObject.Object, FreeCAD.Vector(child.Dir)) sv0 = Draft.make_shape2dview(selectedObject.Object, FreeCAD.Vector(child.Dir))
break break
print("FAILURE IF")
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()
sk = Draft.make_sketch(sv0, autoconstraints=True) sk = Draft.make_sketch(sv0, autoconstraints=True)
sk.ViewObject.LineColor = (1.0, 0.0, 0.0) sk.ViewObject.LineColor = (1.0, 0.0, 0.0)
@ -131,7 +133,7 @@ class WindowDialog():
if hasattr(sv0, 'Name'): if hasattr(sv0, 'Name'):
App.ActiveDocument.removeObject(sv0.Name) App.ActiveDocument.removeObject(sv0.Name)
except Exception as e: except Exception as e:
print("FAILURE TRY") print(e)
if isCalepinage: if isCalepinage:
self._exportSketchCalepinage(sketchList, plateLength, plateWidth, spacing, laserSize) self._exportSketchCalepinage(sketchList, plateLength, plateWidth, spacing, laserSize)
@ -142,4 +144,7 @@ class WindowDialog():
if __name__ == '__main__': if __name__ == '__main__':
try:
d = WindowDialog() d = WindowDialog()
except Exception as e:
print(e)