From d2f5dcebc28fbbcb8b0cf31c5e1c2000e313ca3f Mon Sep 17 00:00:00 2001 From: tarman3 Date: Tue, 2 Sep 2025 20:50:44 +0300 Subject: [PATCH] CAM: Create stock height 1 mm for flat objects --- src/Mod/CAM/Path/Main/Stock.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Mod/CAM/Path/Main/Stock.py b/src/Mod/CAM/Path/Main/Stock.py index bf0293c82d..09f4d3ff6c 100644 --- a/src/Mod/CAM/Path/Main/Stock.py +++ b/src/Mod/CAM/Path/Main/Stock.py @@ -70,7 +70,7 @@ class StockType: def shapeBoundBox(obj): Path.Log.track(type(obj)) - if list == type(obj) and obj: + if isinstance(obj, list) and obj: bb = FreeCAD.BoundBox() for o in obj: bb.add(shapeBoundBox(o)) @@ -106,6 +106,8 @@ class Stock(object): class StockFromBase(Stock): + MinExtent = 1 + def __init__(self, obj, base): "Make stock" obj.addProperty( @@ -210,6 +212,10 @@ class StockFromBase(Stock): self.length = bb.XLength + obj.ExtXneg.Value + obj.ExtXpos.Value self.width = bb.YLength + obj.ExtYneg.Value + obj.ExtYpos.Value + + if bb.ZLength + obj.ExtZneg.Value + obj.ExtZpos.Value <= 0: + Path.Log.error("Stock height can not be zero or negative\nSet ExtZneg = 1 mm") + obj.ExtZneg.Value = self.MinExtent self.height = bb.ZLength + obj.ExtZneg.Value + obj.ExtZpos.Value shape = Part.makeBox(self.length, self.width, self.height, self.origin) @@ -219,7 +225,7 @@ class StockFromBase(Stock): def onChanged(self, obj, prop): if ( prop in ["ExtXneg", "ExtXpos", "ExtYneg", "ExtYpos", "ExtZneg", "ExtZpos"] - and not "Restore" in obj.State + and "Restore" not in obj.State ): self.execute(obj) @@ -272,7 +278,7 @@ class StockCreateBox(Stock): obj.Shape = shape def onChanged(self, obj, prop): - if prop in ["Length", "Width", "Height"] and not "Restore" in obj.State: + if prop in ["Length", "Width", "Height"] and "Restore" not in obj.State: self.execute(obj) @@ -315,7 +321,7 @@ class StockCreateCylinder(Stock): obj.Shape = shape def onChanged(self, obj, prop): - if prop in ["Radius", "Height"] and not "Restore" in obj.State: + if prop in ["Radius", "Height"] and "Restore" not in obj.State: self.execute(obj)