Part::Thickness: This fixes issue #2876 by changing property type for value to include a unit.
This commit is contained in:
@@ -491,6 +491,9 @@ Thickness::Thickness()
|
||||
Join.setEnums(JoinEnums);
|
||||
ADD_PROPERTY_TYPE(Intersection,(false),"Thickness",App::Prop_None,"Intersection");
|
||||
ADD_PROPERTY_TYPE(SelfIntersection,(false),"Thickness",App::Prop_None,"Self Intersection");
|
||||
|
||||
// Value should have length as unit
|
||||
Value.setUnit(Base::Unit::Length);
|
||||
}
|
||||
|
||||
short Thickness::mustExecute() const
|
||||
@@ -510,6 +513,17 @@ short Thickness::mustExecute() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Thickness::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop)
|
||||
{
|
||||
if (prop == &Value && strcmp(TypeName, "App::PropertyFloat") == 0) {
|
||||
App::PropertyFloat v;
|
||||
|
||||
v.Restore(reader);
|
||||
|
||||
Value.setValue(v.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Thickness::execute(void)
|
||||
{
|
||||
App::DocumentObject* source = Faces.getValue();
|
||||
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
Thickness();
|
||||
|
||||
App::PropertyLinkSub Faces;
|
||||
App::PropertyFloat Value;
|
||||
App::PropertyQuantity Value;
|
||||
App::PropertyEnumeration Mode;
|
||||
App::PropertyEnumeration Join;
|
||||
App::PropertyBool Intersection;
|
||||
@@ -139,6 +139,9 @@ public:
|
||||
}
|
||||
//@}
|
||||
|
||||
protected:
|
||||
void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop);
|
||||
|
||||
private:
|
||||
static const char* ModeEnums[];
|
||||
static const char* JoinEnums[];
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
import FreeCAD, os, sys, unittest, Part
|
||||
import copy
|
||||
from FreeCAD import Units
|
||||
App = FreeCAD
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -90,6 +91,26 @@ class PartTestBSplineCurve(unittest.TestCase):
|
||||
# spline.setOrigin(2) # not working?
|
||||
self.spline.setPole(1, App.Vector([1, 0, 0])) # first parameter 0 gives occ error
|
||||
|
||||
def testIssue2876(self):
|
||||
self.Doc = App.newDocument("Issue2876")
|
||||
Cylinder = self.Doc.addObject("Part::Cylinder", "Cylinder")
|
||||
Cylinder.Radius = 5
|
||||
Pipe = self.Doc.addObject("Part::Thickness", "Pipe")
|
||||
Pipe.Faces = (Cylinder, ["Face2", "Face3"])
|
||||
Pipe.Mode = 1
|
||||
Pipe.Value = -1 # negative wall thickness
|
||||
Spreadsheet = self.Doc.addObject('Spreadsheet::Sheet', 'Spreadsheet')
|
||||
Spreadsheet.set('A1', 'Pipe OD')
|
||||
Spreadsheet.set('B1', 'Pipe WT')
|
||||
Spreadsheet.set('C1', 'Pipe ID')
|
||||
Spreadsheet.set('A2', '=2*Cylinder.Radius')
|
||||
Spreadsheet.set('B2', '=-Pipe.Value')
|
||||
Spreadsheet.set('C2', '=2*(Cylinder.Radius + Pipe.Value)')
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(Spreadsheet.B2, Units.Quantity('1 mm'))
|
||||
self.assertEqual(Spreadsheet.C2, Units.Quantity('8 mm'))
|
||||
App.closeDocument("Issue2876")
|
||||
|
||||
def tearDown(self):
|
||||
#closing doc
|
||||
FreeCAD.closeDocument("PartTest")
|
||||
|
||||
@@ -495,7 +495,7 @@ class SpreadsheetCases(unittest.TestCase):
|
||||
self.doc.addObject("Part::Thickness", "Pipe")
|
||||
sheet.set('B1', '101')
|
||||
sheet.set('A53', '=-(-(B1-1)/2)')
|
||||
sheet.set('A54', '=-(Cylinder.Radius + Pipe.Value*1mm - 1"/2)')
|
||||
sheet.set('A54', '=-(Cylinder.Radius + Pipe.Value - 1"/2)')
|
||||
|
||||
self.doc.recompute()
|
||||
self.assertEqual(sheet.getContents("A1"), "=1 < 2 ? 3 : 4")
|
||||
|
||||
Reference in New Issue
Block a user