Upgrade Toponaming tests
This commit is contained in:
@@ -26,8 +26,8 @@
|
||||
import unittest
|
||||
|
||||
import FreeCAD as App
|
||||
# import Part
|
||||
# import Sketcher
|
||||
import Part
|
||||
import Sketcher
|
||||
import TestSketcherApp
|
||||
|
||||
|
||||
@@ -110,39 +110,490 @@ class TestTopologicalNamingProblem(unittest.TestCase):
|
||||
else:
|
||||
print("TOPOLOGICAL NAMING PROBLEM IS PRESENT.")
|
||||
|
||||
# def testFutureStuff(self):
|
||||
# self.Doc.getObject('Body').newObject('Sketcher::SketchObject', 'Sketch')
|
||||
# geoList = []
|
||||
# geoList.append(Part.LineSegment(App.Vector(0,0,0),App.Vector(20,0,0)))
|
||||
# geoList.append(Part.LineSegment(App.Vector(20,0,0),App.Vector(20,10,0)))
|
||||
# geoList.append(Part.LineSegment(App.Vector(20,10,0),App.Vector(10,10,0)))
|
||||
# geoList.append(Part.LineSegment(App.Vector(10,10,0),App.Vector(10,20,0)))
|
||||
# geoList.append(Part.LineSegment(App.Vector(10,20,0),App.Vector(0,20,0)))
|
||||
# geoList.append(Part.LineSegment(App.Vector(0,20,0),App.Vector(0,0,0)))
|
||||
# self.Doc.getObject('Sketch').addGeometry(geoList,False)
|
||||
# conList = []
|
||||
# conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
|
||||
# conList.append(Sketcher.Constraint('Coincident',1,2,2,1))
|
||||
# conList.append(Sketcher.Constraint('Coincident',2,2,3,1))
|
||||
# conList.append(Sketcher.Constraint('Coincident',3,2,4,1))
|
||||
# conList.append(Sketcher.Constraint('Coincident',4,2,5,1))
|
||||
# conList.append(Sketcher.Constraint('Coincident',5,2,0,1))
|
||||
# conList.append(Sketcher.Constraint('Horizontal',0))
|
||||
# conList.append(Sketcher.Constraint('Horizontal',2))
|
||||
# conList.append(Sketcher.Constraint('Horizontal',4))
|
||||
# conList.append(Sketcher.Constraint('Vertical',1))
|
||||
# conList.append(Sketcher.Constraint('Vertical',3))
|
||||
# conList.append(Sketcher.Constraint('Vertical',5))
|
||||
# self.Doc.getObject('Sketch').addConstraint(conList)
|
||||
# del geoList, conList
|
||||
# self.Doc.recompute()
|
||||
# self.Doc.getObject('Body').newObject('PartDesign::Pad','Pad002')
|
||||
# self.Doc.getObject('Pad002').Length = 10
|
||||
# self.Doc.Pad002.Profile = self.Doc.Sketch
|
||||
# self.Doc.recompute()
|
||||
# self.Doc.getObject('Pad002').ReferenceAxis = (self.Doc.getObject('Sketch'),['N_Axis'])
|
||||
# self.Doc.getObject('Sketch').Visibility = False
|
||||
def testPartDesignElementMapBox(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box')
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act / Assert
|
||||
self.assertEqual(len(box.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(box.Shape.childShapes()), 1)
|
||||
self.assertEqual(box.Shape.childShapes()[0].ElementMapSize, 26)
|
||||
body.addObject(box)
|
||||
self.assertEqual(len(body.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 26)
|
||||
|
||||
def testPartDesignElementMapCylinder(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
cylinder = self.Doc.addObject('PartDesign::AdditiveCylinder', 'Cylinder')
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act / Assert
|
||||
self.assertEqual(len(cylinder.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(cylinder.Shape.childShapes()), 1)
|
||||
self.assertEqual(cylinder.Shape.childShapes()[0].ElementMapSize, 8)
|
||||
body.addObject(cylinder)
|
||||
self.assertEqual(len(body.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 8)
|
||||
|
||||
def testPartDesignElementMapSphere(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
sphere = self.Doc.addObject('PartDesign::AdditiveSphere', 'Sphere')
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act / Assert
|
||||
self.assertEqual(len(sphere.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(sphere.Shape.childShapes()), 1)
|
||||
self.assertEqual(sphere.Shape.childShapes()[0].ElementMapSize, 6)
|
||||
body.addObject(sphere)
|
||||
self.assertEqual(len(body.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 6)
|
||||
|
||||
def testPartDesignElementMapCone(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
cone = self.Doc.addObject('PartDesign::AdditiveCone', 'Cone')
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act / Assert
|
||||
self.assertEqual(len(cone.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(cone.Shape.childShapes()), 1)
|
||||
self.assertEqual(cone.Shape.childShapes()[0].ElementMapSize, 8)
|
||||
body.addObject(cone)
|
||||
self.assertEqual(len(body.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 8)
|
||||
|
||||
def testPartDesignElementMapEllipsoid(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
ellipsoid = self.Doc.addObject('PartDesign::AdditiveEllipsoid', 'Ellipsoid')
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act / Assert
|
||||
self.assertEqual(len(ellipsoid.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(ellipsoid.Shape.childShapes()), 1)
|
||||
self.assertEqual(ellipsoid.Shape.childShapes()[0].ElementMapSize, 6)
|
||||
body.addObject(ellipsoid)
|
||||
self.assertEqual(len(body.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 6)
|
||||
|
||||
def testPartDesignElementMapTorus(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
torus = self.Doc.addObject('PartDesign::AdditiveTorus', 'Torus')
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act / Assert
|
||||
self.assertEqual(len(torus.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(torus.Shape.childShapes()), 1)
|
||||
self.assertEqual(torus.Shape.childShapes()[0].ElementMapSize, 4)
|
||||
body.addObject(torus)
|
||||
self.assertEqual(len(body.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 4)
|
||||
|
||||
def testPartDesignElementMapPrism(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
prism = self.Doc.addObject('PartDesign::AdditivePrism', 'Prism')
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act / Assert
|
||||
self.assertEqual(len(prism.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(prism.Shape.childShapes()), 1)
|
||||
self.assertEqual(prism.Shape.childShapes()[0].ElementMapSize, 38)
|
||||
body.addObject(prism)
|
||||
self.assertEqual(len(body.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 38)
|
||||
|
||||
def testPartDesignElementMapWedge(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
wedge = self.Doc.addObject('PartDesign::AdditiveWedge', 'Wedge')
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act / Assert
|
||||
self.assertEqual(len(wedge.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(wedge.Shape.childShapes()), 1)
|
||||
self.assertEqual(wedge.Shape.childShapes()[0].ElementMapSize, 26)
|
||||
body.addObject(wedge)
|
||||
self.assertEqual(len(body.Shape.childShapes()), 0)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 26)
|
||||
|
||||
# body.BaseFeature = box
|
||||
|
||||
def testPartDesignElementMapSubBox(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box')
|
||||
box.Length = 20
|
||||
box.Width = 20
|
||||
box.Height = 20
|
||||
body.addObject(box)
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act
|
||||
subbox = self.Doc.addObject('PartDesign::SubtractiveBox', 'Box')
|
||||
subbox.BaseFeature = box
|
||||
body.addObject(subbox)
|
||||
self.Doc.recompute()
|
||||
# Assert
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 44)
|
||||
|
||||
def testPartDesignElementMapSubCylinder(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box')
|
||||
box.Length = 20
|
||||
box.Width = 20
|
||||
box.Height = 20
|
||||
body.addObject(box)
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act
|
||||
subcylinder = self.Doc.addObject('PartDesign::SubtractiveCylinder', 'Cylinder')
|
||||
subcylinder.BaseFeature = box
|
||||
body.addObject(subcylinder)
|
||||
# Assert
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 38)
|
||||
|
||||
def testPartDesignElementMapSubSphere(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box')
|
||||
box.Length = 20
|
||||
box.Width = 20
|
||||
box.Height = 20
|
||||
body.addObject(box)
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act
|
||||
subsphere = self.Doc.addObject('PartDesign::SubtractiveSphere', 'Sphere')
|
||||
subsphere.BaseFeature = box
|
||||
body.addObject(subsphere)
|
||||
self.Doc.recompute()
|
||||
# Assert
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 33)
|
||||
|
||||
def testPartDesignElementMapSubCone(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box')
|
||||
box.Length = 20
|
||||
box.Width = 20
|
||||
box.Height = 20
|
||||
body.addObject(box)
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act
|
||||
subcone = self.Doc.addObject('PartDesign::SubtractiveCone', 'Cone')
|
||||
subcone.BaseFeature = box
|
||||
body.addObject(subcone)
|
||||
# Assert
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 38)
|
||||
|
||||
def testPartDesignElementMapSubEllipsoid(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box')
|
||||
box.Length = 20
|
||||
box.Width = 20
|
||||
box.Height = 20
|
||||
body.addObject(box)
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act
|
||||
subellipsoid = self.Doc.addObject('PartDesign::SubtractiveEllipsoid', 'Ellipsoid')
|
||||
subellipsoid.BaseFeature = box
|
||||
body.addObject(subellipsoid)
|
||||
self.Doc.recompute()
|
||||
# Assert
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 33)
|
||||
|
||||
def testPartDesignElementMapSubTorus(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box')
|
||||
box.Length = 20
|
||||
box.Width = 20
|
||||
box.Height = 20
|
||||
body.addObject(box)
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act
|
||||
subtorus = self.Doc.addObject('PartDesign::SubtractiveTorus', 'Torus')
|
||||
subtorus.BaseFeature = box
|
||||
body.addObject(subtorus)
|
||||
self.Doc.recompute()
|
||||
# Assert
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 38)
|
||||
|
||||
def testPartDesignElementMapSubPrism(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box')
|
||||
box.Length = 20
|
||||
box.Width = 20
|
||||
box.Height = 20
|
||||
body.addObject(box)
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act
|
||||
subprism = self.Doc.addObject('PartDesign::SubtractivePrism', 'Prism')
|
||||
subprism.BaseFeature = box
|
||||
body.addObject(subprism)
|
||||
self.Doc.recompute()
|
||||
# Assert
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 44)
|
||||
|
||||
def testPartDesignElementMapSubWedge(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box')
|
||||
box.Length = 20
|
||||
box.Width = 20
|
||||
box.Height = 20
|
||||
body.addObject(box)
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act
|
||||
subwedge = self.Doc.addObject('PartDesign::SubtractiveWedge', 'Wedge')
|
||||
subwedge.BaseFeature = box
|
||||
body.addObject(subwedge)
|
||||
self.Doc.recompute()
|
||||
# Assert
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 50)
|
||||
|
||||
def testPartDesignElementMapSketch(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch')
|
||||
TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1))
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act
|
||||
pad = self.Doc.addObject('PartDesign::Pad', 'Pad')
|
||||
pad.Profile = sketch
|
||||
pad.BaseFeature = sketch
|
||||
body.addObject(sketch)
|
||||
body.addObject(pad)
|
||||
self.Doc.recompute()
|
||||
# Assert
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 26)
|
||||
|
||||
def testPartDesignElementMapRevolution(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch')
|
||||
TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1))
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act
|
||||
revolution = self.Doc.addObject('PartDesign::Revolution', 'Revolution')
|
||||
revolution.ReferenceAxis = body.Origin.OriginFeatures[1]
|
||||
revolution.Profile = sketch # Causing segfault
|
||||
body.addObject(sketch)
|
||||
body.addObject(revolution)
|
||||
self.Doc.recompute()
|
||||
# Assert
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 8)
|
||||
|
||||
def testPartDesignElementMapLoft(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch')
|
||||
TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1))
|
||||
sketch2 = self.Doc.addObject('Sketcher::SketchObject', 'Sketch')
|
||||
TestSketcherApp.CreateRectangleSketch(sketch2, (0, 0), (2, 2))
|
||||
sketch2.Placement.move(App.Vector(0, 0, 3))
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act
|
||||
loft = self.Doc.addObject('PartDesign::AdditiveLoft', 'Loft')
|
||||
loft.Profile = sketch
|
||||
loft.Sections = [sketch2]
|
||||
body.addObject(sketch)
|
||||
body.addObject(sketch2)
|
||||
body.addObject(loft)
|
||||
self.Doc.recompute()
|
||||
# Assert
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 26)
|
||||
|
||||
def testPartDesignElementMapPipe(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch')
|
||||
TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1))
|
||||
sketch2 = self.Doc.addObject('Sketcher::SketchObject', 'Sketch')
|
||||
TestSketcherApp.CreateRectangleSketch(sketch2, (0, 0), (2, 2))
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act
|
||||
pipe = self.Doc.addObject('PartDesign::AdditivePipe', 'Pipe')
|
||||
pipe.Profile = sketch
|
||||
pipe.Spine = sketch2
|
||||
body.addObject(sketch)
|
||||
body.addObject(sketch2)
|
||||
body.addObject(pipe)
|
||||
self.Doc.recompute()
|
||||
# Assert
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 64)
|
||||
|
||||
def testPartDesignElementMapHelix(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch')
|
||||
TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1))
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Act
|
||||
helix = self.Doc.addObject('PartDesign::AdditiveHelix', 'Helix')
|
||||
helix.Profile = sketch
|
||||
helix.ReferenceAxis = body.Origin.OriginFeatures[2]
|
||||
body.addObject(sketch)
|
||||
body.addObject(helix)
|
||||
self.Doc.recompute()
|
||||
# Assert
|
||||
self.assertEqual(len(body.Shape.childShapes()), 1)
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 26)
|
||||
|
||||
def testPartDesignElementMapPocket(self):
|
||||
pass # TODO
|
||||
|
||||
def testPartDesignElementMapHole(self):
|
||||
pass # TODO
|
||||
|
||||
def testPartDesignElementMapGroove(self):
|
||||
# Arrange
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box')
|
||||
body.addObject(box)
|
||||
|
||||
groove = self.Doc.addObject('PartDesign::Groove', 'Groove')
|
||||
body.addObject(groove)
|
||||
groove.ReferenceAxis = (self.Doc.getObject('Y_Axis'), [''])
|
||||
groove.Angle = 360.0
|
||||
groove.Profile = (box, ['Face6'])
|
||||
groove.ReferenceAxis = (box, ['Edge9'])
|
||||
groove.Midplane = 0
|
||||
groove.Reversed = 0
|
||||
groove.Base = App.Vector(0, 0, 0)
|
||||
self.Doc.recompute()
|
||||
# Assert
|
||||
# print(groove.Shape.childShapes()[0].ElementMap)
|
||||
# TODO: Complete me as part of the subtractive features
|
||||
|
||||
def testPartDesignElementMapSubLoft(self):
|
||||
pass # TODO
|
||||
|
||||
def testPartDesignElementMapSubPipe(self):
|
||||
pass # TODO
|
||||
|
||||
def testPartDesignElementMapSubHelix(self):
|
||||
pass # TODO
|
||||
|
||||
def testSketchElementMap(self):
|
||||
body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch')
|
||||
TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1))
|
||||
body.addObject(sketch)
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(sketch.Shape.ElementMapSize, 12)
|
||||
pad = self.Doc.addObject('PartDesign::Pad', 'Pad')
|
||||
pad.Profile = sketch
|
||||
body.addObject(pad)
|
||||
self.Doc.recompute()
|
||||
if not hasattr(body,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Assert
|
||||
self.assertEqual(sketch.Shape.ElementMapSize, 12)
|
||||
self.assertEqual(pad.Shape.ElementMapSize, 30) # The sketch plus the pad in the map
|
||||
# TODO: differing results between main and LS3 on these values. Does it matter?
|
||||
# self.assertEqual(body.Shape.ElementMapSize,0) # 8?
|
||||
# self.Doc.recompute()
|
||||
# self.assertEqual(body.Shape.ElementMapSize,30) # 26
|
||||
|
||||
def testPlaneElementMap(self):
|
||||
plane = self.Doc.addObject("Part::Plane", "Plane")
|
||||
plane.Length = 10
|
||||
plane.Width = 10
|
||||
self.Doc.recompute()
|
||||
self.assertEqual(plane.Shape.ElementMapSize, 0)
|
||||
pad = self.Doc.addObject('PartDesign::Pad', 'Pad')
|
||||
pad.Profile = plane
|
||||
self.Doc.recompute()
|
||||
if not hasattr(pad,"ElementMapVersion"): # Skip without element maps.
|
||||
return
|
||||
# Assert
|
||||
self.assertEqual(plane.Shape.ElementMapSize, 0)
|
||||
self.assertEqual(pad.Shape.ElementMapSize, 26)
|
||||
|
||||
def create_t_sketch(self):
|
||||
self.Doc.getObject('Body').newObject('Sketcher::SketchObject', 'Sketch')
|
||||
geo_list = [
|
||||
Part.LineSegment(App.Vector(0, 0, 0), App.Vector(20, 0, 0)),
|
||||
Part.LineSegment(App.Vector(20, 0, 0), App.Vector(20, 10, 0)),
|
||||
Part.LineSegment(App.Vector(20, 10, 0), App.Vector(10, 10, 0)),
|
||||
Part.LineSegment(App.Vector(10, 10, 0), App.Vector(10, 20, 0)),
|
||||
Part.LineSegment(App.Vector(10, 20, 0), App.Vector(0, 20, 0)),
|
||||
Part.LineSegment(App.Vector(0, 20, 0), App.Vector(0, 0, 0))]
|
||||
self.Doc.getObject('Sketch').addGeometry(geo_list, False)
|
||||
con_list = [
|
||||
Sketcher.Constraint('Coincident', 0, 2, 1, 1),
|
||||
Sketcher.Constraint('Coincident', 1, 2, 2, 1),
|
||||
Sketcher.Constraint('Coincident', 2, 2, 3, 1),
|
||||
Sketcher.Constraint('Coincident', 3, 2, 4, 1),
|
||||
Sketcher.Constraint('Coincident', 4, 2, 5, 1),
|
||||
Sketcher.Constraint('Coincident', 5, 2, 0, 1),
|
||||
Sketcher.Constraint('Horizontal', 0),
|
||||
Sketcher.Constraint('Horizontal', 2),
|
||||
Sketcher.Constraint('Horizontal', 4),
|
||||
Sketcher.Constraint('Vertical', 1),
|
||||
Sketcher.Constraint('Vertical', 3),
|
||||
Sketcher.Constraint('Vertical', 5)]
|
||||
self.Doc.getObject('Sketch').addConstraint(con_list)
|
||||
del geo_list, con_list
|
||||
self.Doc.recompute()
|
||||
|
||||
def tearDown(self):
|
||||
""" Close our test document """
|
||||
|
||||
Reference in New Issue
Block a user