Deal with temporary invalid data for stock extents and ensure minimum size.

This commit is contained in:
Markus Lampert
2017-09-14 16:55:10 -07:00
committed by wmayer
parent c40e737492
commit a6fc367064
2 changed files with 38 additions and 16 deletions

View File

@@ -291,15 +291,18 @@ class StockCreateBoxEdit(StockEdit):
return self.form.stockCreateBox
def getFields(self, obj, fields = ['length', 'widht', 'height']):
if self.IsStock(obj):
if 'length' in fields:
obj.Stock.Length = FreeCAD.Units.Quantity(self.form.stockBoxLength.text())
if 'width' in fields:
obj.Stock.Width = FreeCAD.Units.Quantity(self.form.stockBoxWidth.text())
if 'height' in fields:
obj.Stock.Height = FreeCAD.Units.Quantity(self.form.stockBoxHeight.text())
else:
PathLog.error(translate('PathJob', 'Stock not a box!'))
try:
if self.IsStock(obj):
if 'length' in fields:
obj.Stock.Length = FreeCAD.Units.Quantity(self.form.stockBoxLength.text())
if 'width' in fields:
obj.Stock.Width = FreeCAD.Units.Quantity(self.form.stockBoxWidth.text())
if 'height' in fields:
obj.Stock.Height = FreeCAD.Units.Quantity(self.form.stockBoxHeight.text())
else:
PathLog.error(translate('PathJob', 'Stock not a box!'))
except:
pass
def setFields(self, obj):
if not self.IsStock(obj):
@@ -322,13 +325,16 @@ class StockCreateCylinderEdit(StockEdit):
return self.form.stockCreateCylinder
def getFields(self, obj, fields = ['radius', 'height']):
if self.IsStock(obj):
if 'radius' in fields:
obj.Stock.Radius = FreeCAD.Units.Quantity(self.form.stockCylinderRadius.text())
if 'height' in fields:
obj.Stock.Height = FreeCAD.Units.Quantity(self.form.stockCylinderHeight.text())
else:
PathLog.error(translate('PathJob', 'Stock not a cylinder!'))
try:
if self.IsStock(obj):
if 'radius' in fields:
obj.Stock.Radius = FreeCAD.Units.Quantity(self.form.stockCylinderRadius.text())
if 'height' in fields:
obj.Stock.Height = FreeCAD.Units.Quantity(self.form.stockCylinderHeight.text())
else:
PathLog.error(translate('PathJob', 'Stock not a cylinder!'))
except:
pass
def setFields(self, obj):
if not self.IsStock(obj):