diff --git a/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py b/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py index 82e189ce6c..c6a4228b5a 100644 --- a/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py +++ b/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py @@ -33,31 +33,33 @@ import TestSketcherApp class TestTopologicalNamingProblem(unittest.TestCase): - """ Tests related to the Topological Naming Problem """ + """Tests related to the Topological Naming Problem""" # pylint: disable=attribute-defined-outside-init def setUp(self): - """ Create a document for each test in the test suite """ + """Create a document for each test in the test suite""" self.Doc = App.newDocument("PartDesignTestTNP." + self._testMethodName) def countFacesEdgesVertexes(self, map): + """Helper to return a tuple of the counts of Faces, Edges, and Vertexes in a map for + easier test writing""" faces = [name for name in map.keys() if name.startswith("Face")] edges = [name for name in map.keys() if name.startswith("Edge")] vertexes = [name for name in map.keys() if name.startswith("Vertex")] return (len(faces), len(edges), len(vertexes)) def testPadsOnBaseObject(self): - """ Simple TNP test case - By creating three Pads dependent on each other in succession, and then moving the - middle one we can determine if the last one breaks because of a broken reference - to the middle one. This is the essence of a TNP. Pretty much a duplicate of the - steps at https://wiki.freecad.org/Topological_naming_problem """ + """Simple TNP test case + By creating three Pads dependent on each other in succession, and then moving the + middle one we can determine if the last one breaks because of a broken reference + to the middle one. This is the essence of a TNP. Pretty much a duplicate of the + steps at https://wiki.freecad.org/Topological_naming_problem""" # Arrange - self.Body = self.Doc.addObject('PartDesign::Body', 'Body') + self.Body = self.Doc.addObject("PartDesign::Body", "Body") # Make first offset cube Pad - self.PadSketch = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad') + self.PadSketch = self.Doc.addObject("Sketcher::SketchObject", "SketchPad") self.Body.addObject(self.PadSketch) TestSketcherApp.CreateRectangleSketch(self.PadSketch, (0, 0), (1, 1)) self.Doc.recompute() @@ -68,10 +70,10 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.Doc.recompute() # Attach a second pad to the top of the first. - self.PadSketch1 = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad1') + self.PadSketch1 = self.Doc.addObject("Sketcher::SketchObject", "SketchPad1") self.Body.addObject(self.PadSketch1) - self.PadSketch1.MapMode = 'FlatFace' - self.PadSketch1.AttachmentSupport = [(self.Doc.getObject('Pad'), 'Face6')] + self.PadSketch1.MapMode = "FlatFace" + self.PadSketch1.AttachmentSupport = [(self.Doc.getObject("Pad"), "Face6")] TestSketcherApp.CreateRectangleSketch(self.PadSketch1, (0, 0), (1, 1)) self.Doc.recompute() self.Pad1 = self.Doc.addObject("PartDesign::Pad", "Pad1") @@ -81,10 +83,10 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.Doc.recompute() # Attach a third pad to the top of the second. - self.PadSketch2 = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad2') + self.PadSketch2 = self.Doc.addObject("Sketcher::SketchObject", "SketchPad2") self.Body.addObject(self.PadSketch2) - self.PadSketch2.MapMode = 'FlatFace' - self.PadSketch2.AttachmentSupport = [(self.Doc.getObject('Pad1'), 'Face6')] + self.PadSketch2.MapMode = "FlatFace" + self.PadSketch2.AttachmentSupport = [(self.Doc.getObject("Pad1"), "Face6")] TestSketcherApp.CreateRectangleSketch(self.PadSketch2, (0, 0), (1, 1)) self.Doc.recompute() self.Pad2 = self.Doc.addObject("PartDesign::Pad", "Pad2") @@ -102,7 +104,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): # Move the second pad ( the sketch attachment point ) self.PadSketch1.AttachmentOffset = App.Placement( App.Vector(0.5000000000, 0.0000000000, 0.0000000000), - App.Rotation(0.0000000000, 0.0000000000, 0.0000000000)) + App.Rotation(0.0000000000, 0.0000000000, 0.0000000000), + ) self.Doc.recompute() # Assert everything is still valid. @@ -110,15 +113,19 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertTrue(self.Pad1.isValid()) if self.Body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. - self.assertFalse(self.Pad2.isValid()) # TNP problem is present without ElementMaps + self.assertFalse( + self.Pad2.isValid() + ) # TNP problem is present without ElementMaps else: - self.assertTrue(self.Pad2.isValid()) # TNP problem is not present with ElementMaps + self.assertTrue( + self.Pad2.isValid() + ) # TNP problem is not present with ElementMaps def testPartDesignElementMapSketch(self): - """ Test that creating a sketch results in a correct element map. """ + """Test that creating a sketch results in a correct element map.""" # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - sketch = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad') + body = self.Doc.addObject("PartDesign::Body", "Body") + sketch = self.Doc.addObject("Sketcher::SketchObject", "SketchPad") body.addObject(sketch) TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1)) # Act @@ -136,40 +143,41 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertEqual(len(edges), 4) self.assertEqual(len(vertexes), 4) - def testPartDesignBasicFusion(self): - """ Test that a basic fusion creates an element map, and refine retains it """ + """Test that a basic fusion creates an element map, and refine retains it""" # Arrange doc = self.Doc - box1 = doc.addObject("Part::Box","Box") + box1 = doc.addObject("Part::Box", "Box") if App.GuiUp: mat = App.Material() - mat.AmbientColor = (128,0,0) - box1.ViewObject.ShapeAppearance = mat # Change color ( material ) for at least one - box2 = doc.addObject("Part::Box","Box001") - box3 = doc.addObject("Part::Box","Box002") - cyl1 = doc.addObject("Part::Cylinder","Cylinder") - fuse1 = doc.addObject("Part::MultiFuse","Fusion") + mat.AmbientColor = (128, 0, 0) + box1.ViewObject.ShapeAppearance = ( + mat # Change color ( material ) for at least one + ) + box2 = doc.addObject("Part::Box", "Box001") + box3 = doc.addObject("Part::Box", "Box002") + cyl1 = doc.addObject("Part::Cylinder", "Cylinder") + fuse1 = doc.addObject("Part::MultiFuse", "Fusion") doc.Fusion.Shapes = [box1, box2] - fuse2 = doc.addObject("Part::MultiFuse","Fusion001") + fuse2 = doc.addObject("Part::MultiFuse", "Fusion001") doc.Fusion001.Shapes = [box3, cyl1] doc.recompute() # Assert - self.assertEqual(fuse1.Shape.ElementMapSize,26) - self.assertEqual(fuse2.Shape.ElementMapSize,44) + self.assertEqual(fuse1.Shape.ElementMapSize, 26) + self.assertEqual(fuse2.Shape.ElementMapSize, 44) # Act doc.Fusion.Refine = True # activate refinement doc.Fusion001.Refine = True # activate refinement doc.recompute() - self.assertEqual(fuse1.Shape.ElementMapSize,26) - self.assertEqual(fuse2.Shape.ElementMapSize,44) + self.assertEqual(fuse1.Shape.ElementMapSize, 26) + self.assertEqual(fuse2.Shape.ElementMapSize, 44) def testPartDesignElementMapPad(self): - """ Test that padding a sketch results in a correct element map. Note that comprehensive testing - of the geometric functionality of the Pad is in TestPad.py """ + """Test that padding a sketch results in a correct element map. Note that comprehensive + testing of the geometric functionality of the Pad is in TestPad.py""" # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - padSketch = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad') + body = self.Doc.addObject("PartDesign::Body", "Body") + padSketch = self.Doc.addObject("Sketcher::SketchObject", "SketchPad") pad = self.Doc.addObject("PartDesign::Pad", "Pad") body.addObject(padSketch) body.addObject(pad) @@ -193,8 +201,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapBox(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert @@ -210,8 +218,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapCylinder(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - cylinder = self.Doc.addObject('PartDesign::AdditiveCylinder', 'Cylinder') + body = self.Doc.addObject("PartDesign::Body", "Body") + cylinder = self.Doc.addObject("PartDesign::AdditiveCylinder", "Cylinder") if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert @@ -235,8 +243,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapSphere(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - sphere = self.Doc.addObject('PartDesign::AdditiveSphere', 'Sphere') + body = self.Doc.addObject("PartDesign::Body", "Body") + sphere = self.Doc.addObject("PartDesign::AdditiveSphere", "Sphere") if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert @@ -260,8 +268,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapCone(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - cone = self.Doc.addObject('PartDesign::AdditiveCone', 'Cone') + body = self.Doc.addObject("PartDesign::Body", "Body") + cone = self.Doc.addObject("PartDesign::AdditiveCone", "Cone") if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert @@ -285,8 +293,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapEllipsoid(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - ellipsoid = self.Doc.addObject('PartDesign::AdditiveEllipsoid', 'Ellipsoid') + body = self.Doc.addObject("PartDesign::Body", "Body") + ellipsoid = self.Doc.addObject("PartDesign::AdditiveEllipsoid", "Ellipsoid") if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert @@ -310,8 +318,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapTorus(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - torus = self.Doc.addObject('PartDesign::AdditiveTorus', 'Torus') + body = self.Doc.addObject("PartDesign::Body", "Body") + torus = self.Doc.addObject("PartDesign::AdditiveTorus", "Torus") if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert @@ -335,8 +343,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapPrism(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - prism = self.Doc.addObject('PartDesign::AdditivePrism', 'Prism') + body = self.Doc.addObject("PartDesign::Body", "Body") + prism = self.Doc.addObject("PartDesign::AdditivePrism", "Prism") if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert @@ -360,8 +368,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapWedge(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - wedge = self.Doc.addObject('PartDesign::AdditiveWedge', 'Wedge') + body = self.Doc.addObject("PartDesign::Body", "Body") + wedge = self.Doc.addObject("PartDesign::AdditiveWedge", "Wedge") if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert @@ -387,8 +395,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapSubBox(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") box.Length = 20 box.Width = 20 box.Height = 20 @@ -396,7 +404,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - subbox = self.Doc.addObject('PartDesign::SubtractiveBox', 'Box') + subbox = self.Doc.addObject("PartDesign::SubtractiveBox", "Box") subbox.BaseFeature = box body.addObject(subbox) self.Doc.recompute() @@ -406,8 +414,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapSubCylinder(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") box.Length = 20 box.Width = 20 box.Height = 20 @@ -415,7 +423,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - subcylinder = self.Doc.addObject('PartDesign::SubtractiveCylinder', 'Cylinder') + subcylinder = self.Doc.addObject("PartDesign::SubtractiveCylinder", "Cylinder") subcylinder.BaseFeature = box body.addObject(subcylinder) # Assert @@ -425,8 +433,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapSubSphere(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") box.Length = 20 box.Width = 20 box.Height = 20 @@ -434,7 +442,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - subsphere = self.Doc.addObject('PartDesign::SubtractiveSphere', 'Sphere') + subsphere = self.Doc.addObject("PartDesign::SubtractiveSphere", "Sphere") subsphere.BaseFeature = box body.addObject(subsphere) self.Doc.recompute() @@ -444,8 +452,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapSubCone(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") box.Length = 20 box.Width = 20 box.Height = 20 @@ -453,7 +461,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - subcone = self.Doc.addObject('PartDesign::SubtractiveCone', 'Cone') + subcone = self.Doc.addObject("PartDesign::SubtractiveCone", "Cone") subcone.BaseFeature = box body.addObject(subcone) # Assert @@ -463,8 +471,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapSubEllipsoid(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") box.Length = 20 box.Width = 20 box.Height = 20 @@ -472,7 +480,9 @@ class TestTopologicalNamingProblem(unittest.TestCase): if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - subellipsoid = self.Doc.addObject('PartDesign::SubtractiveEllipsoid', 'Ellipsoid') + subellipsoid = self.Doc.addObject( + "PartDesign::SubtractiveEllipsoid", "Ellipsoid" + ) subellipsoid.BaseFeature = box body.addObject(subellipsoid) self.Doc.recompute() @@ -482,8 +492,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapSubTorus(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") box.Length = 20 box.Width = 20 box.Height = 20 @@ -491,7 +501,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - subtorus = self.Doc.addObject('PartDesign::SubtractiveTorus', 'Torus') + subtorus = self.Doc.addObject("PartDesign::SubtractiveTorus", "Torus") subtorus.BaseFeature = box body.addObject(subtorus) self.Doc.recompute() @@ -501,8 +511,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapSubPrism(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") box.Length = 20 box.Width = 20 box.Height = 20 @@ -510,7 +520,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - subprism = self.Doc.addObject('PartDesign::SubtractivePrism', 'Prism') + subprism = self.Doc.addObject("PartDesign::SubtractivePrism", "Prism") subprism.BaseFeature = box body.addObject(subprism) self.Doc.recompute() @@ -520,8 +530,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapSubWedge(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") box.Length = 20 box.Width = 20 box.Height = 20 @@ -529,7 +539,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - subwedge = self.Doc.addObject('PartDesign::SubtractiveWedge', 'Wedge') + subwedge = self.Doc.addObject("PartDesign::SubtractiveWedge", "Wedge") subwedge.BaseFeature = box body.addObject(subwedge) self.Doc.recompute() @@ -539,25 +549,31 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementPadSketch(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') + body = self.Doc.addObject("PartDesign::Body", "Body") + sketch = self.Doc.addObject("Sketcher::SketchObject", "Sketch") TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1)) if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - pad = self.Doc.addObject('PartDesign::Pad', 'Pad') + pad = self.Doc.addObject("PartDesign::Pad", "Pad") pad.Profile = 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, 30) # The pad - self.assertEqual(body.Shape.ElementMapSize,26) - self.assertEqual(sketch.Shape.ElementMapSize,12) - self.assertEqual(pad.Shape.ElementMapSize,30) # pad has the 26 plus the 4 original - self.assertNotEqual(pad.Shape.ElementReverseMap['Vertex1'],"Vertex1") # NewName, not OldName - self.assertEqual(self.countFacesEdgesVertexes(pad.Shape.ElementReverseMap),(6,12,8)) + self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 30) # The pad + self.assertEqual(body.Shape.ElementMapSize, 26) + self.assertEqual(sketch.Shape.ElementMapSize, 12) + self.assertEqual( + pad.Shape.ElementMapSize, 30 + ) # pad has the 26 plus the 4 original + self.assertNotEqual( + pad.Shape.ElementReverseMap["Vertex1"], "Vertex1" + ) # NewName, not OldName + self.assertEqual( + self.countFacesEdgesVertexes(pad.Shape.ElementReverseMap), (6, 12, 8) + ) # Todo: Offer a way to turn on hashing and check that with a # starting # Pad -> Extrusion -> makes compounds and does booleans, thus the resulting newName element maps @@ -565,14 +581,14 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapRevolution(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') + body = self.Doc.addObject("PartDesign::Body", "Body") + sketch = self.Doc.addObject("Sketcher::SketchObject", "Sketch") TestSketcherApp.CreateRectangleSketch(sketch, (1, 1), (2, 2)) # (pt), (w,l) if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - revolution = self.Doc.addObject('PartDesign::Revolution', 'Revolution') - revolution.ReferenceAxis = (self.Doc.getObject('Sketch'), ['V_Axis']) + revolution = self.Doc.addObject("PartDesign::Revolution", "Revolution") + revolution.ReferenceAxis = (self.Doc.getObject("Sketch"), ["V_Axis"]) revolution.Profile = sketch body.addObject(sketch) body.addObject(revolution) @@ -581,23 +597,24 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertEqual(len(body.Shape.childShapes()), 1) self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 14) self.assertEqual(revolution.Shape.ElementMapSize, 14) - self.assertEqual(self.countFacesEdgesVertexes(revolution.Shape.ElementReverseMap), - (4, 6, 4)) + self.assertEqual( + self.countFacesEdgesVertexes(revolution.Shape.ElementReverseMap), (4, 6, 4) + ) volume = (math.pi * 3 * 3 - math.pi * 1 * 1) * 2 # 50.26548245743668 self.assertAlmostEqual(revolution.Shape.Volume, volume) def testPartDesignElementMapLoft(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') + 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') + sketch2 = self.Doc.addObject("Sketcher::SketchObject", "Sketch") TestSketcherApp.CreateRectangleSketch(sketch2, (0, 0), (2, 2)) sketch2.Placement.move(App.Vector(0, 0, 3)) if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - loft = self.Doc.addObject('PartDesign::AdditiveLoft', 'Loft') + loft = self.Doc.addObject("PartDesign::AdditiveLoft", "Loft") loft.Profile = sketch loft.Sections = [sketch2] body.addObject(sketch) @@ -611,28 +628,30 @@ class TestTopologicalNamingProblem(unittest.TestCase): # 4 vertexes are quad dups for 12 more. 26 + 4 + 12 = 42 # self.assertEqual(body.Shape.ElementMapSize, 42) revMap = body.Shape.ElementReverseMap - self.assertNotEqual(loft.Shape.ElementReverseMap['Vertex1'], "Vertex1") - self.assertNotEqual(revMap['Vertex1'], "Vertex1") - self.assertEqual(self.countFacesEdgesVertexes(loft.Shape.ElementReverseMap), (6, 12, 8)) + self.assertNotEqual(loft.Shape.ElementReverseMap["Vertex1"], "Vertex1") + self.assertNotEqual(revMap["Vertex1"], "Vertex1") + self.assertEqual( + self.countFacesEdgesVertexes(loft.Shape.ElementReverseMap), (6, 12, 8) + ) volume = 7.0 self.assertAlmostEqual(loft.Shape.Volume, volume) def testPartDesignElementMapPipe(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') + 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', 'Sketch001') - sketch2.AttachmentSupport = (self.Doc.getObject("XZ_Plane"), ['']) - sketch2.addGeometry(Part.LineSegment(App.Vector(0, 0, 0), - App.Vector(0, 1, 0))) - sketch2.Placement = App.Placement(App.Vector(0, 0, 0), - App.Rotation(App.Vector(1.00, 0.00, 0.00), 90.00)) + sketch2 = self.Doc.addObject("Sketcher::SketchObject", "Sketch001") + sketch2.AttachmentSupport = (self.Doc.getObject("XZ_Plane"), [""]) + sketch2.addGeometry(Part.LineSegment(App.Vector(0, 0, 0), App.Vector(0, 1, 0))) + sketch2.Placement = App.Placement( + App.Vector(0, 0, 0), App.Rotation(App.Vector(1.00, 0.00, 0.00), 90.00) + ) # Need to set sketch2 placement? if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - pipe = self.Doc.addObject('PartDesign::AdditivePipe', 'Pipe') + pipe = self.Doc.addObject("PartDesign::AdditivePipe", "Pipe") pipe.Profile = sketch pipe.Spine = sketch2 body.addObject(sketch) @@ -653,19 +672,19 @@ class TestTopologicalNamingProblem(unittest.TestCase): # revMap = pipe.Shape.ElementReverseMap # TODO: This is a child of the body and not the actual Pipe. # 1: is that okay and normal, or should the pipe have an element map - self.assertEqual(self.countFacesEdgesVertexes(revMap),(6,12,8)) + self.assertEqual(self.countFacesEdgesVertexes(revMap), (6, 12, 8)) 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)) + body = self.Doc.addObject("PartDesign::Body", "Body") + sketch = self.Doc.addObject("Sketcher::SketchObject", "Sketch") + TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1)) if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - helix = self.Doc.addObject('PartDesign::AdditiveHelix', 'Helix') + helix = self.Doc.addObject("PartDesign::AdditiveHelix", "Helix") helix.Profile = sketch - helix.ReferenceAxis = (self.Doc.getObject('Sketch'), ['N_Axis']) + helix.ReferenceAxis = (self.Doc.getObject("Sketch"), ["N_Axis"]) # helix.Mode = 0 body.addObject(sketch) body.addObject(helix) @@ -675,12 +694,15 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertGreaterEqual(body.Shape.childShapes()[0].ElementMapSize, 26) revMap = body.Shape.childShapes()[0].ElementReverseMap self.assertEqual(self.countFacesEdgesVertexes(revMap), (14, 28, 16)) - Radius = 0 # Rectangle is on the axis, but wouldn't matter regardless here + Radius = 0 # Rectangle is on the axis, but wouldn't matter regardless here Area = Part.Face(sketch.Shape).Area # General helix formula; not actually used here since devolves to just the # height in this orientation. - helixLength = (helix.Height.Value / helix.Pitch.Value * - math.sqrt( (math.pi * Radius) ** 2 + helix.Pitch.Value ** 2)) + helixLength = ( + helix.Height.Value + / helix.Pitch.Value + * math.sqrt((math.pi * Radius) ** 2 + helix.Pitch.Value**2) + ) Volume = Area * helixLength self.assertAlmostEqual(Area, 1) self.assertAlmostEqual(helixLength, helix.Height.Value) @@ -689,21 +711,21 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapPocket(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") body.addObject(box) - sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') - sketch.AttachmentSupport = (box, 'Face6') - sketch.MapMode = 'FlatFace' + sketch = self.Doc.addObject("Sketcher::SketchObject", "Sketch") + sketch.AttachmentSupport = (box, "Face6") + sketch.MapMode = "FlatFace" TestSketcherApp.CreateRectangleSketch(sketch, (1, 1), (1, 1)) if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - pocket = self.Doc.addObject('PartDesign::Pocket', 'Pocket') + pocket = self.Doc.addObject("PartDesign::Pocket", "Pocket") pocket.Profile = sketch pocket.Length = 5 pocket.Direction = (0, 0, -1) - pocket.ReferenceAxis = (sketch, ['N_Axis']) + pocket.ReferenceAxis = (sketch, ["N_Axis"]) pocket.Refine = True body.addObject(sketch) @@ -712,27 +734,31 @@ class TestTopologicalNamingProblem(unittest.TestCase): # Assert self.assertEqual(len(body.Shape.childShapes()), 1) self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 55) - self.assertEqual(body.Shape.ElementMapSize,51) - self.assertEqual(sketch.Shape.ElementMapSize,12) - self.assertEqual(pocket.Shape.ElementMapSize,55) - self.assertNotEqual(pocket.Shape.ElementReverseMap['Vertex1'],"Vertex1") # NewName, not OldName - self.assertEqual(self.countFacesEdgesVertexes(pocket.Shape.ElementReverseMap),(11,24,16)) + self.assertEqual(body.Shape.ElementMapSize, 51) + self.assertEqual(sketch.Shape.ElementMapSize, 12) + self.assertEqual(pocket.Shape.ElementMapSize, 55) + self.assertNotEqual( + pocket.Shape.ElementReverseMap["Vertex1"], "Vertex1" + ) # NewName, not OldName + self.assertEqual( + self.countFacesEdgesVertexes(pocket.Shape.ElementReverseMap), (11, 24, 16) + ) volume = 1000 - 5 * 1 * 1 self.assertAlmostEqual(pocket.Shape.Volume, volume) def testPartDesignElementMapHole(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") body.addObject(box) - sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') - sketch.AttachmentSupport = (box, 'Face6') - sketch.MapMode = 'FlatFace' + sketch = self.Doc.addObject("Sketcher::SketchObject", "Sketch") + sketch.AttachmentSupport = (box, "Face6") + sketch.MapMode = "FlatFace" TestSketcherApp.CreateCircleSketch(sketch, (5, 5), 1) if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - hole = self.Doc.addObject('PartDesign::Hole', 'Hole') + hole = self.Doc.addObject("PartDesign::Hole", "Hole") hole.Profile = sketch body.addObject(sketch) @@ -745,21 +771,23 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertEqual(sketch.Shape.ElementMapSize, 2) self.assertEqual(hole.Shape.ElementMapSize, 32) # self.assertNotEqual(hole.Shape.ElementReverseMap['Vertex1'],"Vertex1") # NewName, not OldName - self.assertEqual(self.countFacesEdgesVertexes(hole.Shape.ElementReverseMap), (7, 15, 10)) + self.assertEqual( + self.countFacesEdgesVertexes(hole.Shape.ElementReverseMap), (7, 15, 10) + ) volume = 1000 - 10 * math.pi * 3 * 3 self.assertAlmostEqual(hole.Shape.Volume, volume) def testPartDesignElementMapGroove(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") body.addObject(box) - groove = self.Doc.addObject('PartDesign::Groove', 'Groove') + groove = self.Doc.addObject("PartDesign::Groove", "Groove") body.addObject(groove) - groove.ReferenceAxis = (self.Doc.getObject('Y_Axis'), ['']) + groove.ReferenceAxis = (self.Doc.getObject("Y_Axis"), [""]) groove.Angle = 360.0 - groove.Profile = (box, ['Face6']) - groove.ReferenceAxis = (box, ['Edge9']) + groove.Profile = (box, ["Face6"]) + groove.ReferenceAxis = (box, ["Edge9"]) groove.Midplane = 0 groove.Reversed = 0 groove.Base = App.Vector(0, 0, 0) @@ -767,25 +795,27 @@ class TestTopologicalNamingProblem(unittest.TestCase): if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Assert - revMap = groove.Shape.ElementReverseMap # body.Shape.childShapes()[0].ElementReverseMap + revMap = ( + groove.Shape.ElementReverseMap + ) # body.Shape.childShapes()[0].ElementReverseMap self.assertEqual(self.countFacesEdgesVertexes(revMap), (5, 9, 6)) volume = 785.3981633974482 # TODO: math formula to calc this. Maybe make a sketch as the Profile. self.assertAlmostEqual(groove.Shape.Volume, volume) def testPartDesignElementMapSubLoft(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") body.addObject(box) - sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') + sketch = self.Doc.addObject("Sketcher::SketchObject", "Sketch") TestSketcherApp.CreateRectangleSketch(sketch, (1, 1), (1, 1)) - sketch2 = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') + sketch2 = self.Doc.addObject("Sketcher::SketchObject", "Sketch") TestSketcherApp.CreateRectangleSketch(sketch2, (1, 1), (2, 2)) sketch2.Placement.move(App.Vector(0, 0, 3)) if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - loft = self.Doc.addObject('PartDesign::SubtractiveLoft', 'SubLoft') + loft = self.Doc.addObject("PartDesign::SubtractiveLoft", "SubLoft") loft.Profile = sketch loft.Sections = [sketch2] body.addObject(loft) @@ -793,29 +823,31 @@ class TestTopologicalNamingProblem(unittest.TestCase): if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Assert - revMap = loft.Shape.ElementReverseMap # body.Shape.childShapes()[0].ElementReverseMap + revMap = ( + loft.Shape.ElementReverseMap + ) # body.Shape.childShapes()[0].ElementReverseMap self.assertEqual(self.countFacesEdgesVertexes(revMap), (11, 24, 16)) volume = 993 # TODO: math formula to calc this. self.assertAlmostEqual(loft.Shape.Volume, volume) def testPartDesignElementMapSubPipe(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") body.addObject(box) - sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') + sketch = self.Doc.addObject("Sketcher::SketchObject", "Sketch") TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1)) - sketch2 = self.Doc.addObject('Sketcher::SketchObject', 'Sketch001') - sketch2.AttachmentSupport = (self.Doc.getObject("XZ_Plane"), ['']) - sketch2.addGeometry(Part.LineSegment(App.Vector(0, 0, 0), - App.Vector(0, 1, 0))) - sketch2.Placement = App.Placement(App.Vector(0, 0, 0), - App.Rotation(App.Vector(1.00, 0.00, 0.00), 90.00)) + sketch2 = self.Doc.addObject("Sketcher::SketchObject", "Sketch001") + sketch2.AttachmentSupport = (self.Doc.getObject("XZ_Plane"), [""]) + sketch2.addGeometry(Part.LineSegment(App.Vector(0, 0, 0), App.Vector(0, 1, 0))) + sketch2.Placement = App.Placement( + App.Vector(0, 0, 0), App.Rotation(App.Vector(1.00, 0.00, 0.00), 90.00) + ) # Need to set sketch2 placement? if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - pipe = self.Doc.addObject('PartDesign::SubtractivePipe', 'SubPipe') + pipe = self.Doc.addObject("PartDesign::SubtractivePipe", "SubPipe") pipe.Profile = sketch pipe.Spine = sketch2 body.addObject(sketch) @@ -832,22 +864,22 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertAlmostEqual(body.Shape.BoundBox.ZMax, 10) self.assertEqual(len(body.Shape.childShapes()), 1) self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 44) - revMap = body.Shape.ElementReverseMap # - self.assertEqual(self.countFacesEdgesVertexes(revMap),(9,21,14)) + revMap = body.Shape.ElementReverseMap # + self.assertEqual(self.countFacesEdgesVertexes(revMap), (9, 21, 14)) def testPartDesignElementMapSubHelix(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") body.addObject(box) - sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') + sketch = self.Doc.addObject("Sketcher::SketchObject", "Sketch") TestSketcherApp.CreateRectangleSketch(sketch, (5, 5), (1, 1)) if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act - helix = self.Doc.addObject('PartDesign::SubtractiveHelix', 'SubHelix') + helix = self.Doc.addObject("PartDesign::SubtractiveHelix", "SubHelix") helix.Profile = sketch - helix.ReferenceAxis = (self.Doc.getObject('Sketch'), ['V_Axis']) + helix.ReferenceAxis = (self.Doc.getObject("Sketch"), ["V_Axis"]) body.addObject(sketch) body.addObject(helix) self.Doc.recompute() @@ -860,26 +892,30 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertAlmostEqual(helix.Shape.Volume, volume, 4) def testPartDesignElementMapChamfer(self): - """ Test Chamfer ( and FeatureDressup )""" + """Test Chamfer ( and FeatureDressup )""" # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") if body.Shape.ElementMapVersion == "": # Skip without element maps. return - chamfer = self.Doc.addObject('PartDesign::Chamfer', 'Chamfer') - chamfer.Base = (box, ['Edge1', - 'Edge2', - 'Edge3', - 'Edge4', - 'Edge5', - 'Edge6', - 'Edge7', - 'Edge8', - 'Edge9', - 'Edge10', - 'Edge11', - 'Edge12', - ]) + chamfer = self.Doc.addObject("PartDesign::Chamfer", "Chamfer") + chamfer.Base = ( + box, + [ + "Edge1", + "Edge2", + "Edge3", + "Edge4", + "Edge5", + "Edge6", + "Edge7", + "Edge8", + "Edge9", + "Edge10", + "Edge11", + "Edge12", + ], + ) chamfer.Size = 1 chamfer.UseAllEdges = True # Act / Assert @@ -898,26 +934,30 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertEqual(len(vertexes), 24) # 8 Vertices become 24 def testPartDesignElementMapFillet(self): - """ Test Fillet ( and FeatureDressup )""" + """Test Fillet ( and FeatureDressup )""" # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") if body.Shape.ElementMapVersion == "": # Skip without element maps. return - fillet = self.Doc.addObject('PartDesign::Fillet', 'Fillet') - fillet.Base = (box, ['Edge1', - 'Edge2', - 'Edge3', - 'Edge4', - 'Edge5', - 'Edge6', - 'Edge7', - 'Edge8', - 'Edge9', - 'Edge10', - 'Edge11', - 'Edge12', - ]) + fillet = self.Doc.addObject("PartDesign::Fillet", "Fillet") + fillet.Base = ( + box, + [ + "Edge1", + "Edge2", + "Edge3", + "Edge4", + "Edge5", + "Edge6", + "Edge7", + "Edge8", + "Edge9", + "Edge10", + "Edge11", + "Edge12", + ], + ) # Act / Assert body.addObject(box) body.addObject(fillet) @@ -935,12 +975,14 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapTransform(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") if body.Shape.ElementMapVersion == "": # Skip without element maps. return - multitransform = self.Doc.addObject('PartDesign::MultiTransform', 'MultiTransform') - scaled = self.Doc.addObject('PartDesign::Scaled', 'Scaled') + multitransform = self.Doc.addObject( + "PartDesign::MultiTransform", "MultiTransform" + ) + scaled = self.Doc.addObject("PartDesign::Scaled", "Scaled") scaled.Factor = 2 scaled.Occurrences = 2 multitransform.Transformations = scaled @@ -957,9 +999,9 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapShapeBinder(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') - shapebinder = self.Doc.addObject('PartDesign::ShapeBinder', 'ShapeBinder') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") + shapebinder = self.Doc.addObject("PartDesign::ShapeBinder", "ShapeBinder") if body.Shape.ElementMapVersion == "": # Skip without element maps. return # Act / Assert @@ -972,9 +1014,11 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testPartDesignElementMapSubShapeBinder(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') - subshapebinder = self.Doc.addObject('PartDesign::SubShapeBinder', 'SubShapeBinder') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") + subshapebinder = self.Doc.addObject( + "PartDesign::SubShapeBinder", "SubShapeBinder" + ) if body.Shape.ElementMapVersion == "": # Skip without element maps. return # Act / Assert @@ -987,13 +1031,13 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertEqual(subshapebinder.Shape.childShapes()[0].ElementMapSize, 9) def testSketchElementMap(self): - body = self.Doc.addObject('PartDesign::Body', 'Body') - sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') + 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 = self.Doc.addObject("PartDesign::Pad", "Pad") pad.Profile = sketch body.addObject(pad) self.Doc.recompute() @@ -1001,7 +1045,9 @@ class TestTopologicalNamingProblem(unittest.TestCase): return # Assert self.assertEqual(sketch.Shape.ElementMapSize, 12) - self.assertEqual(pad.Shape.ElementMapSize, 30) # The sketch plus the pad in the map + 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.assertEqual(body.Shape.ElementMapSize,30) # 26 @@ -1012,7 +1058,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): plane.Width = 10 self.Doc.recompute() self.assertEqual(plane.Shape.ElementMapSize, 0) - pad = self.Doc.addObject('PartDesign::Pad', 'Pad') + pad = self.Doc.addObject("PartDesign::Pad", "Pad") pad.Profile = plane self.Doc.recompute() if pad.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. @@ -1025,9 +1071,9 @@ class TestTopologicalNamingProblem(unittest.TestCase): # Arrange doc = self.Doc - body = doc.addObject('PartDesign::Body', 'Body') + body = doc.addObject("PartDesign::Body", "Body") # Make first offset cube Pad - padSketch = doc.addObject('Sketcher::SketchObject', 'Sketch') + padSketch = doc.addObject("Sketcher::SketchObject", "Sketch") body.addObject(padSketch) TestSketcherApp.CreateRectangleSketch(padSketch, (0, 0), (31.37, 25.2)) doc.recompute() @@ -1037,32 +1083,42 @@ class TestTopologicalNamingProblem(unittest.TestCase): pad.Length = 10 doc.recompute() - sketch001 = body.newObject('Sketcher::SketchObject', 'Sketch001') + sketch001 = body.newObject("Sketcher::SketchObject", "Sketch001") sketch001 = doc.Sketch001 - sketch001.AttachmentSupport = (doc.getObject('Pad'), ['Face6', ]) - sketch001.MapMode = 'FlatFace' + sketch001.AttachmentSupport = ( + doc.getObject("Pad"), + [ + "Face6", + ], + ) + sketch001.MapMode = "FlatFace" App.ActiveDocument.recompute() geoList = [] - geoList.append(Part.Circle(App.Vector(15.093666, 13.036922, 0.000000), - App.Vector(0.000000, 0.000000, 1.000000), 5.000000)) + geoList.append( + Part.Circle( + App.Vector(15.093666, 13.036922, 0.000000), + App.Vector(0.000000, 0.000000, 1.000000), + 5.000000, + ) + ) sketch001.addGeometry(geoList, False) del geoList - sketch001.addConstraint(Sketcher.Constraint('Radius', 0, 5.000000)) + sketch001.addConstraint(Sketcher.Constraint("Radius", 0, 5.000000)) doc.recompute() - pad001 = body.newObject('PartDesign::Pad', 'Pad001') - pad001.Profile = doc.getObject('Sketch001') + pad001 = body.newObject("PartDesign::Pad", "Pad001") + pad001.Profile = doc.getObject("Sketch001") pad001.Length = 10 App.ActiveDocument.recompute() - pad001.ReferenceAxis = (doc.getObject('Sketch001'), ['N_Axis']) + pad001.ReferenceAxis = (doc.getObject("Sketch001"), ["N_Axis"]) sketch001.Visibility = False App.ActiveDocument.recompute() pad001.Length = 10.000000 pad001.TaperAngle = 0.000000 pad001.UseCustomVector = 0 pad001.Direction = (0, 0, 1) - pad001.ReferenceAxis = (doc.getObject('Sketch001'), ['N_Axis']) + pad001.ReferenceAxis = (doc.getObject("Sketch001"), ["N_Axis"]) pad001.AlongSketchNormal = 1 pad001.Type = 0 pad001.UpToFace = None @@ -1070,32 +1126,48 @@ class TestTopologicalNamingProblem(unittest.TestCase): pad001.Midplane = 0 pad001.Offset = 0 doc.recompute() - doc.getObject('Pad').Visibility = False + doc.getObject("Pad").Visibility = False - doc.getObject('Sketch001').Visibility = False + doc.getObject("Sketch001").Visibility = False # Modify the original sketch to generate TNP issue geoList = [] - geoList.append(Part.LineSegment(App.Vector(2.510468, 22.837425, 0.000000), - App.Vector(2.510468, 19.933617, 0.000000))) - geoList.append(Part.LineSegment(App.Vector(2.510468, 19.933617, 0.000000), - App.Vector(4.869811, 19.933617, 0.000000))) - geoList.append(Part.LineSegment(App.Vector(4.869811, 19.933617, 0.000000), - App.Vector(4.869811, 22.837425, 0.000000))) - geoList.append(Part.LineSegment(App.Vector(4.869811, 22.837425, 0.000000), - App.Vector(2.510468, 22.837425, 0.000000))) + geoList.append( + Part.LineSegment( + App.Vector(2.510468, 22.837425, 0.000000), + App.Vector(2.510468, 19.933617, 0.000000), + ) + ) + geoList.append( + Part.LineSegment( + App.Vector(2.510468, 19.933617, 0.000000), + App.Vector(4.869811, 19.933617, 0.000000), + ) + ) + geoList.append( + Part.LineSegment( + App.Vector(4.869811, 19.933617, 0.000000), + App.Vector(4.869811, 22.837425, 0.000000), + ) + ) + geoList.append( + Part.LineSegment( + App.Vector(4.869811, 22.837425, 0.000000), + App.Vector(2.510468, 22.837425, 0.000000), + ) + ) padSketch.addGeometry(geoList, False) del geoList constraintList = [] - constraintList.append(Sketcher.Constraint('Coincident', 4, 2, 5, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 5, 2, 6, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 6, 2, 7, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 7, 2, 4, 1)) - constraintList.append(Sketcher.Constraint('Vertical', 4)) - constraintList.append(Sketcher.Constraint('Vertical', 6)) - constraintList.append(Sketcher.Constraint('Horizontal', 5)) - constraintList.append(Sketcher.Constraint('Horizontal', 7)) + constraintList.append(Sketcher.Constraint("Coincident", 4, 2, 5, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 5, 2, 6, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 6, 2, 7, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 7, 2, 4, 1)) + constraintList.append(Sketcher.Constraint("Vertical", 4)) + constraintList.append(Sketcher.Constraint("Vertical", 6)) + constraintList.append(Sketcher.Constraint("Horizontal", 5)) + constraintList.append(Sketcher.Constraint("Horizontal", 7)) padSketch.addConstraint(constraintList) del constraintList doc.recompute() @@ -1112,9 +1184,9 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testApplyFillet(self): # Arrange doc = self.Doc - body = doc.addObject('PartDesign::Body', 'Body') + body = doc.addObject("PartDesign::Body", "Body") # Make first offset cube Pad - padSketch = doc.addObject('Sketcher::SketchObject', 'Sketch') + padSketch = doc.addObject("Sketcher::SketchObject", "Sketch") body.addObject(padSketch) TestSketcherApp.CreateRectangleSketch(padSketch, (0, 0), (31.37, 25.2)) doc.recompute() @@ -1124,23 +1196,33 @@ class TestTopologicalNamingProblem(unittest.TestCase): pad.Length = 10 doc.recompute() - sketch001 = body.newObject('Sketcher::SketchObject', 'Sketch001') - sketch001.AttachmentSupport = (doc.getObject('Pad'), ['Face6', ]) - sketch001.MapMode = 'FlatFace' + sketch001 = body.newObject("Sketcher::SketchObject", "Sketch001") + sketch001.AttachmentSupport = ( + doc.getObject("Pad"), + [ + "Face6", + ], + ) + sketch001.MapMode = "FlatFace" geoList = [] - geoList.append(Part.Circle(App.Vector(15.093666, 13.036922, 0.000000), - App.Vector(0.000000, 0.000000, 1.000000), 5.000000)) + geoList.append( + Part.Circle( + App.Vector(15.093666, 13.036922, 0.000000), + App.Vector(0.000000, 0.000000, 1.000000), + 5.000000, + ) + ) sketch001.addGeometry(geoList, False) del geoList - sketch001.addConstraint(Sketcher.Constraint('Radius', 0, 5.000000)) + sketch001.addConstraint(Sketcher.Constraint("Radius", 0, 5.000000)) doc.recompute() - pad001 = body.newObject('PartDesign::Pad', 'Pad001') - pad001.Profile = doc.getObject('Sketch001') + pad001 = body.newObject("PartDesign::Pad", "Pad001") + pad001.Profile = doc.getObject("Sketch001") pad001.Length = 10 App.ActiveDocument.recompute() - pad001.ReferenceAxis = (doc.getObject('Sketch001'), ['N_Axis']) + pad001.ReferenceAxis = (doc.getObject("Sketch001"), ["N_Axis"]) sketch001.Visibility = False App.ActiveDocument.recompute() @@ -1148,7 +1230,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): pad001.TaperAngle = 0.000000 pad001.UseCustomVector = 0 pad001.Direction = (0, 0, 1) - pad001.ReferenceAxis = (doc.getObject('Sketch001'), ['N_Axis']) + pad001.ReferenceAxis = (doc.getObject("Sketch001"), ["N_Axis"]) pad001.AlongSketchNormal = 1 pad001.Type = 0 pad001.UpToFace = None @@ -1156,16 +1238,22 @@ class TestTopologicalNamingProblem(unittest.TestCase): pad001.Midplane = 0 pad001.Offset = 0 doc.recompute() - doc.getObject('Pad').Visibility = False + doc.getObject("Pad").Visibility = False - doc.getObject('Sketch001').Visibility = False + doc.getObject("Sketch001").Visibility = False area1 = pad.Shape.Area # Act - doc.getObject('Sketch').fillet(2, 3, - App.Vector(6.673934, 25.000000, 0), - App.Vector(0.000000, 21.980343, 0), - 4.740471, True, True, False) + doc.getObject("Sketch").fillet( + 2, + 3, + App.Vector(6.673934, 25.000000, 0), + App.Vector(0.000000, 21.980343, 0), + 4.740471, + True, + True, + False, + ) doc.recompute() area2 = pad.Shape.Area @@ -1182,61 +1270,75 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testShapeBinder(self): doc = self.Doc - self.Body = doc.addObject('PartDesign::Body', 'TNP_Test_Body_SubShape') - doc.getObject('TNP_Test_Body_SubShape').Label = 'TNP_Test_Body_SubShape' + self.Body = doc.addObject("PartDesign::Body", "TNP_Test_Body_SubShape") + doc.getObject("TNP_Test_Body_SubShape").Label = "TNP_Test_Body_SubShape" doc.recompute() - doc.getObject('TNP_Test_Body_SubShape').newObject('Sketcher::SketchObject', 'Sketch') - doc.Sketch.AttachmentSupport = (doc.getObject('XY_Plane'), ['']) - doc.Sketch.MapMode = 'FlatFace' + doc.getObject("TNP_Test_Body_SubShape").newObject( + "Sketcher::SketchObject", "Sketch" + ) + doc.Sketch.AttachmentSupport = (doc.getObject("XY_Plane"), [""]) + doc.Sketch.MapMode = "FlatFace" doc.recompute() geoList = [] geoList.append( - Part.LineSegment(App.Vector(0.000000, 0.000000, 0.000000), - App.Vector(35.000000, 0.000000, 0.000000))) + Part.LineSegment( + App.Vector(0.000000, 0.000000, 0.000000), + App.Vector(35.000000, 0.000000, 0.000000), + ) + ) geoList.append( - Part.LineSegment(App.Vector(35.000000, 0.000000, 0.000000), - App.Vector(35.000000, 25.000000, 0.000000))) + Part.LineSegment( + App.Vector(35.000000, 0.000000, 0.000000), + App.Vector(35.000000, 25.000000, 0.000000), + ) + ) geoList.append( - Part.LineSegment(App.Vector(35.000000, 25.000000, 0.000000), - App.Vector(0.000000, 25.000000, 0.000000))) + Part.LineSegment( + App.Vector(35.000000, 25.000000, 0.000000), + App.Vector(0.000000, 25.000000, 0.000000), + ) + ) geoList.append( - Part.LineSegment(App.Vector(0.000000, 25.000000, 0.000000), - App.Vector(0.000000, 0.000000, 0.000000))) + Part.LineSegment( + App.Vector(0.000000, 25.000000, 0.000000), + App.Vector(0.000000, 0.000000, 0.000000), + ) + ) doc.Sketch.addGeometry(geoList, False) del geoList constraintList = [] - constraintList.append(Sketcher.Constraint('Coincident', 0, 2, 1, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 1, 2, 2, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 2, 2, 3, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 3, 2, 0, 1)) - constraintList.append(Sketcher.Constraint('Horizontal', 0)) - constraintList.append(Sketcher.Constraint('Horizontal', 2)) - constraintList.append(Sketcher.Constraint('Vertical', 1)) - constraintList.append(Sketcher.Constraint('Vertical', 3)) + constraintList.append(Sketcher.Constraint("Coincident", 0, 2, 1, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 1, 2, 2, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 2, 2, 3, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 3, 2, 0, 1)) + constraintList.append(Sketcher.Constraint("Horizontal", 0)) + constraintList.append(Sketcher.Constraint("Horizontal", 2)) + constraintList.append(Sketcher.Constraint("Vertical", 1)) + constraintList.append(Sketcher.Constraint("Vertical", 3)) doc.Sketch.addConstraint(constraintList) del constraintList - doc.Sketch.addConstraint(Sketcher.Constraint('Distance', 1, 1, 3, 2, 35.000000)) - doc.Sketch.addConstraint(Sketcher.Constraint('Distance', 0, 1, 2, 2, 25.000000)) - doc.Sketch.addConstraint(Sketcher.Constraint('Coincident', 0, 1, -1, 1)) + doc.Sketch.addConstraint(Sketcher.Constraint("Distance", 1, 1, 3, 2, 35.000000)) + doc.Sketch.addConstraint(Sketcher.Constraint("Distance", 0, 1, 2, 2, 25.000000)) + doc.Sketch.addConstraint(Sketcher.Constraint("Coincident", 0, 1, -1, 1)) doc.recompute() - doc.getObject('TNP_Test_Body_SubShape').newObject('PartDesign::Pad', 'Pad') + doc.getObject("TNP_Test_Body_SubShape").newObject("PartDesign::Pad", "Pad") doc.Pad.Profile = doc.Sketch doc.Pad.Length = 10 doc.recompute() - doc.Pad.ReferenceAxis = (doc.Sketch, ['N_Axis']) + doc.Pad.ReferenceAxis = (doc.Sketch, ["N_Axis"]) doc.Sketch.Visibility = False doc.recompute() doc.Pad.Length = 10.000000 doc.Pad.TaperAngle = 0.000000 doc.Pad.UseCustomVector = 0 doc.Pad.Direction = (0, 0, 1) - doc.Pad.ReferenceAxis = (doc.Sketch, ['N_Axis']) + doc.Pad.ReferenceAxis = (doc.Sketch, ["N_Axis"]) doc.Pad.AlongSketchNormal = 1 doc.Pad.Type = 0 doc.Pad.UpToFace = None @@ -1246,73 +1348,95 @@ class TestTopologicalNamingProblem(unittest.TestCase): doc.recompute() doc.Sketch.Visibility = False - doc.addObject('PartDesign::Body', 'TNP_Test_Body_Second') - doc.getObject('TNP_Test_Body_Second').Label = 'TNP_Test_Body_Second' + doc.addObject("PartDesign::Body", "TNP_Test_Body_Second") + doc.getObject("TNP_Test_Body_Second").Label = "TNP_Test_Body_Second" doc.recompute() - obj = doc.getObject('TNP_Test_Body_Second').newObject('PartDesign::ShapeBinder', - 'ShapeBinder') - obj.Support = (doc.getObject("TNP_Test_Body_SubShape"), [u'Face6']) + obj = doc.getObject("TNP_Test_Body_Second").newObject( + "PartDesign::ShapeBinder", "ShapeBinder" + ) + obj.Support = (doc.getObject("TNP_Test_Body_SubShape"), ["Face6"]) doc.recompute() - doc.getObject('TNP_Test_Body_Second').newObject('Sketcher::SketchObject', 'Sketch001') - doc.getObject('Sketch001').AttachmentSupport = (doc.getObject('ShapeBinder'), ['']) - doc.getObject('Sketch001').MapMode = 'FlatFace' + doc.getObject("TNP_Test_Body_Second").newObject( + "Sketcher::SketchObject", "Sketch001" + ) + doc.getObject("Sketch001").AttachmentSupport = ( + doc.getObject("ShapeBinder"), + [""], + ) + doc.getObject("Sketch001").MapMode = "FlatFace" doc.recompute() geoList = [] geoList.append( - Part.Circle(App.Vector(14.725412, 16.666899, 0.000000), - App.Vector(0.000000, 0.000000, 1.000000), 2.162720)) - doc.getObject('Sketch001').addGeometry(geoList, False) + Part.Circle( + App.Vector(14.725412, 16.666899, 0.000000), + App.Vector(0.000000, 0.000000, 1.000000), + 2.162720, + ) + ) + doc.getObject("Sketch001").addGeometry(geoList, False) del geoList doc.recompute() - doc.getObject('TNP_Test_Body_Second').newObject('PartDesign::Pad', 'Pad001') - doc.getObject('Pad001').Profile = doc.getObject('Sketch001') - doc.getObject('Pad001').Length = 10 + doc.getObject("TNP_Test_Body_Second").newObject("PartDesign::Pad", "Pad001") + doc.getObject("Pad001").Profile = doc.getObject("Sketch001") + doc.getObject("Pad001").Length = 10 doc.recompute() - doc.getObject('Pad001').ReferenceAxis = (doc.getObject('Sketch001'), ['N_Axis']) - doc.getObject('Sketch001').Visibility = False + doc.getObject("Pad001").ReferenceAxis = (doc.getObject("Sketch001"), ["N_Axis"]) + doc.getObject("Sketch001").Visibility = False doc.recompute() - doc.getObject('Pad001').Length = 10.000000 - doc.getObject('Pad001').TaperAngle = 0.000000 - doc.getObject('Pad001').UseCustomVector = 0 - doc.getObject('Pad001').Direction = (0, 0, 1) - doc.getObject('Pad001').ReferenceAxis = (doc.getObject('Sketch001'), ['N_Axis']) - doc.getObject('Pad001').AlongSketchNormal = 1 - doc.getObject('Pad001').Type = 0 - doc.getObject('Pad001').UpToFace = None - doc.getObject('Pad001').Reversed = 0 - doc.getObject('Pad001').Midplane = 0 - doc.getObject('Pad001').Offset = 0 + doc.getObject("Pad001").Length = 10.000000 + doc.getObject("Pad001").TaperAngle = 0.000000 + doc.getObject("Pad001").UseCustomVector = 0 + doc.getObject("Pad001").Direction = (0, 0, 1) + doc.getObject("Pad001").ReferenceAxis = (doc.getObject("Sketch001"), ["N_Axis"]) + doc.getObject("Pad001").AlongSketchNormal = 1 + doc.getObject("Pad001").Type = 0 + doc.getObject("Pad001").UpToFace = None + doc.getObject("Pad001").Reversed = 0 + doc.getObject("Pad001").Midplane = 0 + doc.getObject("Pad001").Offset = 0 doc.recompute() - doc.getObject('ShapeBinder').Visibility = False - doc.getObject('Sketch001').Visibility = False + doc.getObject("ShapeBinder").Visibility = False + doc.getObject("Sketch001").Visibility = False geoList = [] geoList.append( - Part.LineSegment(App.Vector(28.380075, 21.486303, 0.000000), - App.Vector(28.380075, 15.462212, 0.000000))) + Part.LineSegment( + App.Vector(28.380075, 21.486303, 0.000000), + App.Vector(28.380075, 15.462212, 0.000000), + ) + ) geoList.append( - Part.LineSegment(App.Vector(28.380075, 15.462212, 0.000000), - App.Vector(32.797741, 15.462212, 0.000000))) + Part.LineSegment( + App.Vector(28.380075, 15.462212, 0.000000), + App.Vector(32.797741, 15.462212, 0.000000), + ) + ) geoList.append( - Part.LineSegment(App.Vector(32.797741, 15.462212, 0.000000), - App.Vector(32.797741, 21.486303, 0.000000))) + Part.LineSegment( + App.Vector(32.797741, 15.462212, 0.000000), + App.Vector(32.797741, 21.486303, 0.000000), + ) + ) geoList.append( - Part.LineSegment(App.Vector(32.797741, 21.486303, 0.000000), - App.Vector(28.380075, 21.486303, 0.000000))) + Part.LineSegment( + App.Vector(32.797741, 21.486303, 0.000000), + App.Vector(28.380075, 21.486303, 0.000000), + ) + ) doc.Sketch.addGeometry(geoList, False) del geoList constraintList = [] - constraintList.append(Sketcher.Constraint('Coincident', 4, 2, 5, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 5, 2, 6, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 6, 2, 7, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 7, 2, 4, 1)) - constraintList.append(Sketcher.Constraint('Vertical', 4)) - constraintList.append(Sketcher.Constraint('Vertical', 6)) - constraintList.append(Sketcher.Constraint('Horizontal', 5)) - constraintList.append(Sketcher.Constraint('Horizontal', 7)) + constraintList.append(Sketcher.Constraint("Coincident", 4, 2, 5, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 5, 2, 6, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 6, 2, 7, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 7, 2, 4, 1)) + constraintList.append(Sketcher.Constraint("Vertical", 4)) + constraintList.append(Sketcher.Constraint("Vertical", 6)) + constraintList.append(Sketcher.Constraint("Horizontal", 5)) + constraintList.append(Sketcher.Constraint("Horizontal", 7)) doc.Sketch.addConstraint(constraintList) del constraintList @@ -1329,58 +1453,70 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testSubShapeBinder(self): doc = self.Doc - self.Body = doc.addObject('PartDesign::Body', 'Body') - doc.Body.Label = 'Body' + self.Body = doc.addObject("PartDesign::Body", "Body") + doc.Body.Label = "Body" doc.recompute() - doc.Body.newObject('Sketcher::SketchObject', 'Sketch') - doc.Sketch.AttachmentSupport = (doc.getObject('XY_Plane'), ['']) - doc.Sketch.MapMode = 'FlatFace' + doc.Body.newObject("Sketcher::SketchObject", "Sketch") + doc.Sketch.AttachmentSupport = (doc.getObject("XY_Plane"), [""]) + doc.Sketch.MapMode = "FlatFace" doc.recompute() geoList = [] geoList.append( - Part.LineSegment(App.Vector(0.000000, 0.000000, 0.000000), - App.Vector(35.000000, 0.000000, 0.000000))) + Part.LineSegment( + App.Vector(0.000000, 0.000000, 0.000000), + App.Vector(35.000000, 0.000000, 0.000000), + ) + ) geoList.append( - Part.LineSegment(App.Vector(35.000000, 0.000000, 0.000000), - App.Vector(35.000000, 25.000000, 0.000000))) + Part.LineSegment( + App.Vector(35.000000, 0.000000, 0.000000), + App.Vector(35.000000, 25.000000, 0.000000), + ) + ) geoList.append( - Part.LineSegment(App.Vector(35.000000, 25.000000, 0.000000), - App.Vector(0.000000, 25.000000, 0.000000))) + Part.LineSegment( + App.Vector(35.000000, 25.000000, 0.000000), + App.Vector(0.000000, 25.000000, 0.000000), + ) + ) geoList.append( - Part.LineSegment(App.Vector(0.000000, 25.000000, 0.000000), - App.Vector(0.000000, 0.000000, 0.000000))) + Part.LineSegment( + App.Vector(0.000000, 25.000000, 0.000000), + App.Vector(0.000000, 0.000000, 0.000000), + ) + ) doc.Sketch.addGeometry(geoList, False) del geoList constraintList = [] - constraintList.append(Sketcher.Constraint('Coincident', 0, 2, 1, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 1, 2, 2, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 2, 2, 3, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 3, 2, 0, 1)) - constraintList.append(Sketcher.Constraint('Horizontal', 0)) - constraintList.append(Sketcher.Constraint('Horizontal', 2)) - constraintList.append(Sketcher.Constraint('Vertical', 1)) - constraintList.append(Sketcher.Constraint('Vertical', 3)) + constraintList.append(Sketcher.Constraint("Coincident", 0, 2, 1, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 1, 2, 2, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 2, 2, 3, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 3, 2, 0, 1)) + constraintList.append(Sketcher.Constraint("Horizontal", 0)) + constraintList.append(Sketcher.Constraint("Horizontal", 2)) + constraintList.append(Sketcher.Constraint("Vertical", 1)) + constraintList.append(Sketcher.Constraint("Vertical", 3)) doc.Sketch.addConstraint(constraintList) del constraintList - doc.Sketch.addConstraint(Sketcher.Constraint('Distance', 1, 1, 3, 2, 35.000000)) - doc.Sketch.addConstraint(Sketcher.Constraint('Distance', 0, 1, 2, 2, 25.000000)) - doc.Sketch.addConstraint(Sketcher.Constraint('Coincident', 0, 1, -1, 1)) + doc.Sketch.addConstraint(Sketcher.Constraint("Distance", 1, 1, 3, 2, 35.000000)) + doc.Sketch.addConstraint(Sketcher.Constraint("Distance", 0, 1, 2, 2, 25.000000)) + doc.Sketch.addConstraint(Sketcher.Constraint("Coincident", 0, 1, -1, 1)) doc.recompute() - doc.Body.newObject('PartDesign::Pad', 'Pad') + doc.Body.newObject("PartDesign::Pad", "Pad") doc.Pad.Profile = doc.Sketch doc.Pad.Length = 10 doc.recompute() - doc.Pad.ReferenceAxis = (doc.Sketch, ['N_Axis']) + doc.Pad.ReferenceAxis = (doc.Sketch, ["N_Axis"]) doc.Sketch.Visibility = False doc.Pad.Length = 10.000000 doc.Pad.TaperAngle = 0.000000 doc.Pad.UseCustomVector = 0 doc.Pad.Direction = (0, 0, 1) - doc.Pad.ReferenceAxis = (doc.Sketch, ['N_Axis']) + doc.Pad.ReferenceAxis = (doc.Sketch, ["N_Axis"]) doc.Pad.AlongSketchNormal = 1 doc.Pad.Type = 0 doc.Pad.UpToFace = None @@ -1389,37 +1525,48 @@ class TestTopologicalNamingProblem(unittest.TestCase): doc.Pad.Offset = 0 doc.recompute() doc.Sketch.Visibility = False - doc.addObject('PartDesign::Body', 'Body001') - doc.getObject('Body001').Label = 'Body' + doc.addObject("PartDesign::Body", "Body001") + doc.getObject("Body001").Label = "Body" doc.recompute() - binder = doc.getObject('Body001').newObject('PartDesign::SubShapeBinder', 'Binder') + binder = doc.getObject("Body001").newObject( + "PartDesign::SubShapeBinder", "Binder" + ) binder.Support = self.Body - doc.getObject('Body001').newObject('Sketcher::SketchObject', 'Sketch001') - doc.getObject('Sketch001').AttachmentSupport = (doc.getObject('Binder'), ['Face6', ]) - doc.getObject('Sketch001').MapMode = 'FlatFace' + doc.getObject("Body001").newObject("Sketcher::SketchObject", "Sketch001") + doc.getObject("Sketch001").AttachmentSupport = ( + doc.getObject("Binder"), + [ + "Face6", + ], + ) + doc.getObject("Sketch001").MapMode = "FlatFace" doc.recompute() geoList = [] geoList.append( - Part.Circle(App.Vector(16.566162, 13.537925, 0.000000), - App.Vector(0.000000, 0.000000, 1.000000), 2.197371)) - doc.getObject('Sketch001').addGeometry(geoList, False) + Part.Circle( + App.Vector(16.566162, 13.537925, 0.000000), + App.Vector(0.000000, 0.000000, 1.000000), + 2.197371, + ) + ) + doc.getObject("Sketch001").addGeometry(geoList, False) del geoList doc.recompute() ### Begin command PartDesign_Pad - doc.getObject('Body001').newObject('PartDesign::Pad', 'Pad001') - doc.Pad001.Profile = doc.getObject('Sketch001') + doc.getObject("Body001").newObject("PartDesign::Pad", "Pad001") + doc.Pad001.Profile = doc.getObject("Sketch001") doc.Pad001.Length = 10 doc.recompute() - doc.Pad001.ReferenceAxis = (doc.getObject('Sketch001'), ['N_Axis']) - doc.getObject('Sketch001').Visibility = False + doc.Pad001.ReferenceAxis = (doc.getObject("Sketch001"), ["N_Axis"]) + doc.getObject("Sketch001").Visibility = False doc.recompute() doc.Pad001.Length = 10.000000 doc.Pad001.TaperAngle = 0.000000 doc.Pad001.UseCustomVector = 0 doc.Pad001.Direction = (0, 0, 1) - doc.Pad001.ReferenceAxis = (doc.getObject('Sketch001'), ['N_Axis']) + doc.Pad001.ReferenceAxis = (doc.getObject("Sketch001"), ["N_Axis"]) doc.Pad001.AlongSketchNormal = 1 doc.Pad001.Type = 0 doc.Pad001.UpToFace = None @@ -1427,34 +1574,46 @@ class TestTopologicalNamingProblem(unittest.TestCase): doc.Pad001.Midplane = 0 doc.Pad001.Offset = 0 doc.recompute() - doc.getObject('Binder').Visibility = False - doc.getObject('Sketch001').Visibility = False + doc.getObject("Binder").Visibility = False + doc.getObject("Sketch001").Visibility = False geoList = [] geoList.append( - Part.LineSegment(App.Vector(30.009926, 21.026653, 0.000000), - App.Vector(30.009926, 16.425089, 0.000000))) + Part.LineSegment( + App.Vector(30.009926, 21.026653, 0.000000), + App.Vector(30.009926, 16.425089, 0.000000), + ) + ) geoList.append( - Part.LineSegment(App.Vector(30.009926, 16.425089, 0.000000), - App.Vector(31.994911, 16.425089, 0.000000))) + Part.LineSegment( + App.Vector(30.009926, 16.425089, 0.000000), + App.Vector(31.994911, 16.425089, 0.000000), + ) + ) geoList.append( - Part.LineSegment(App.Vector(31.994911, 16.425089, 0.000000), - App.Vector(31.994911, 21.026653, 0.000000))) + Part.LineSegment( + App.Vector(31.994911, 16.425089, 0.000000), + App.Vector(31.994911, 21.026653, 0.000000), + ) + ) geoList.append( - Part.LineSegment(App.Vector(31.994911, 21.026653, 0.000000), - App.Vector(30.009926, 21.026653, 0.000000))) + Part.LineSegment( + App.Vector(31.994911, 21.026653, 0.000000), + App.Vector(30.009926, 21.026653, 0.000000), + ) + ) doc.Sketch.addGeometry(geoList, False) del geoList constraintList = [] - constraintList.append(Sketcher.Constraint('Coincident', 4, 2, 5, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 5, 2, 6, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 6, 2, 7, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 7, 2, 4, 1)) - constraintList.append(Sketcher.Constraint('Vertical', 4)) - constraintList.append(Sketcher.Constraint('Vertical', 6)) - constraintList.append(Sketcher.Constraint('Horizontal', 5)) - constraintList.append(Sketcher.Constraint('Horizontal', 7)) + constraintList.append(Sketcher.Constraint("Coincident", 4, 2, 5, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 5, 2, 6, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 6, 2, 7, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 7, 2, 4, 1)) + constraintList.append(Sketcher.Constraint("Vertical", 4)) + constraintList.append(Sketcher.Constraint("Vertical", 6)) + constraintList.append(Sketcher.Constraint("Horizontal", 5)) + constraintList.append(Sketcher.Constraint("Horizontal", 7)) doc.Sketch.addConstraint(constraintList) del constraintList @@ -1470,60 +1629,69 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertEqual(self.Body.Shape.BoundBox.ZMax, 10) def testPartDesignTNPChamfer(self): - """ Test Chamfer """ + """Test Chamfer""" # Arrange doc = self.Doc - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") body.addObject(box) self.Doc.recompute() volume1 = body.Shape.Volume - chamfer = self.Doc.addObject('PartDesign::Chamfer', 'Chamfer') - chamfer.Base = (box, ['Edge1', - 'Edge5', - 'Edge7', - ]) + chamfer = self.Doc.addObject("PartDesign::Chamfer", "Chamfer") + chamfer.Base = ( + box, + [ + "Edge1", + "Edge5", + "Edge7", + ], + ) chamfer.Size = 1 body.addObject(chamfer) self.Doc.recompute() volume2 = body.Shape.Volume - doc.Body.newObject('Sketcher::SketchObject', 'Sketch') + doc.Body.newObject("Sketcher::SketchObject", "Sketch") doc.Sketch.AttachmentSupport = (chamfer, "Face8") - doc.Sketch.MapMode = 'FlatFace' + doc.Sketch.MapMode = "FlatFace" doc.recompute() - x1, x2, y1, y2 = 10 / math.sqrt(2) - math.sqrt(2), 10 / math.sqrt(2) + math.sqrt(2), 6, 11 + x1, x2, y1, y2 = ( + 10 / math.sqrt(2) - math.sqrt(2), + 10 / math.sqrt(2) + math.sqrt(2), + 6, + 11, + ) geoList = [] geoList.append( - Part.LineSegment(App.Vector(x1, y1, 0.0), - App.Vector(x1, y2, 0.0))) + Part.LineSegment(App.Vector(x1, y1, 0.0), App.Vector(x1, y2, 0.0)) + ) geoList.append( - Part.LineSegment(App.Vector(x1, y2, 0.0), - App.Vector(x2, y2, 0.0))) + Part.LineSegment(App.Vector(x1, y2, 0.0), App.Vector(x2, y2, 0.0)) + ) geoList.append( - Part.LineSegment(App.Vector(x2, y2, 0.0), - App.Vector(x2, y1, 0.0))) + Part.LineSegment(App.Vector(x2, y2, 0.0), App.Vector(x2, y1, 0.0)) + ) geoList.append( - Part.LineSegment(App.Vector(x2, y1, 0.0), - App.Vector(x1, y1, 0.0))) + Part.LineSegment(App.Vector(x2, y1, 0.0), App.Vector(x1, y1, 0.0)) + ) doc.Sketch.addGeometry(geoList, False) del geoList constraintList = [] - constraintList.append(Sketcher.Constraint('Coincident', 0, 2, 1, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 1, 2, 2, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 2, 2, 3, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 3, 2, 0, 1)) - constraintList.append(Sketcher.Constraint('Horizontal', 0)) - constraintList.append(Sketcher.Constraint('Horizontal', 2)) - constraintList.append(Sketcher.Constraint('Vertical', 1)) - constraintList.append(Sketcher.Constraint('Vertical', 3)) + constraintList.append(Sketcher.Constraint("Coincident", 0, 2, 1, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 1, 2, 2, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 2, 2, 3, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 3, 2, 0, 1)) + constraintList.append(Sketcher.Constraint("Horizontal", 0)) + constraintList.append(Sketcher.Constraint("Horizontal", 2)) + constraintList.append(Sketcher.Constraint("Vertical", 1)) + constraintList.append(Sketcher.Constraint("Vertical", 3)) doc.Sketch.addConstraint(constraintList) del constraintList body.addObject(doc.Sketch) - pocket = self.Doc.addObject('PartDesign::Pocket', 'Pocket') + pocket = self.Doc.addObject("PartDesign::Pocket", "Pocket") pocket.Type = "Length" pocket.Length = 3 pocket.Direction = App.Vector(-0.710000000, 0.7100000000, 0.0000000000) @@ -1532,9 +1700,13 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.Doc.recompute() volume3 = body.Shape.Volume # Change the chamfered edges, potentially triggering TNP - chamfer.Base = (box, ['Edge5', - 'Edge7', - ]) + chamfer.Base = ( + box, + [ + "Edge5", + "Edge7", + ], + ) self.Doc.recompute() volume4 = body.Shape.Volume # Assert @@ -1553,7 +1725,9 @@ class TestTopologicalNamingProblem(unittest.TestCase): boxVolume = 10 * 10 * 10 chamferVolume = 1 * 1 * 0.5 * 10 # cut area is rectangle with sqrt(2) as one side minus 2 isosceles right triangles - cutArea = (2 * math.sqrt(2)) * 3 - ((math.sqrt(2) / 2 * math.sqrt(2) / 2) / 2) * 2 + cutArea = (2 * math.sqrt(2)) * 3 - ( + (math.sqrt(2) / 2 * math.sqrt(2) / 2) / 2 + ) * 2 cutVolume = cutArea * 4 # height is 4 ( 11-6 with a limit of 10 from the box ) self.assertAlmostEqual(volume1, boxVolume) self.assertAlmostEqual(volume2, boxVolume - 3 * chamferVolume) @@ -1561,61 +1735,65 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertAlmostEqual(volume4, boxVolume - 2 * chamferVolume - cutVolume, 4) def testPartDesignTNPFillet(self): - """ Test Fillet """ + """Test Fillet""" # Arrange doc = self.Doc - body = self.Doc.addObject('PartDesign::Body', 'Body') - box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') + body = self.Doc.addObject("PartDesign::Body", "Body") + box = self.Doc.addObject("PartDesign::AdditiveBox", "Box") body.addObject(box) self.Doc.recompute() volume1 = body.Shape.Volume - fillet = self.Doc.addObject('PartDesign::Fillet', 'Fillet') + fillet = self.Doc.addObject("PartDesign::Fillet", "Fillet") fillet.Refine = True - fillet.Base = (box, ['Edge1', - 'Edge5', - 'Edge7', - ]) + fillet.Base = ( + box, + [ + "Edge1", + "Edge5", + "Edge7", + ], + ) # fillet.Size = 1 body.addObject(fillet) self.Doc.recompute() volume2 = body.Shape.Volume - doc.Body.newObject('Sketcher::SketchObject', 'Sketch') + doc.Body.newObject("Sketcher::SketchObject", "Sketch") doc.Sketch.AttachmentSupport = (fillet, "Face2") - doc.Sketch.MapMode = 'FlatFace' + doc.Sketch.MapMode = "FlatFace" doc.recompute() x1, x2, y1, y2 = 4, 6, 6, 11 geoList = [] geoList.append( - Part.LineSegment(App.Vector(x1, y1, 0.0), - App.Vector(x1, y2, 0.0))) + Part.LineSegment(App.Vector(x1, y1, 0.0), App.Vector(x1, y2, 0.0)) + ) geoList.append( - Part.LineSegment(App.Vector(x1, y2, 0.0), - App.Vector(x2, y2, 0.0))) + Part.LineSegment(App.Vector(x1, y2, 0.0), App.Vector(x2, y2, 0.0)) + ) geoList.append( - Part.LineSegment(App.Vector(x2, y2, 0.0), - App.Vector(x2, y1, 0.0))) + Part.LineSegment(App.Vector(x2, y2, 0.0), App.Vector(x2, y1, 0.0)) + ) geoList.append( - Part.LineSegment(App.Vector(x2, y1, 0.0), - App.Vector(x1, y1, 0.0))) + Part.LineSegment(App.Vector(x2, y1, 0.0), App.Vector(x1, y1, 0.0)) + ) doc.Sketch.addGeometry(geoList, False) del geoList constraintList = [] - constraintList.append(Sketcher.Constraint('Coincident', 0, 2, 1, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 1, 2, 2, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 2, 2, 3, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 3, 2, 0, 1)) - constraintList.append(Sketcher.Constraint('Horizontal', 0)) - constraintList.append(Sketcher.Constraint('Horizontal', 2)) - constraintList.append(Sketcher.Constraint('Vertical', 1)) - constraintList.append(Sketcher.Constraint('Vertical', 3)) + constraintList.append(Sketcher.Constraint("Coincident", 0, 2, 1, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 1, 2, 2, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 2, 2, 3, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 3, 2, 0, 1)) + constraintList.append(Sketcher.Constraint("Horizontal", 0)) + constraintList.append(Sketcher.Constraint("Horizontal", 2)) + constraintList.append(Sketcher.Constraint("Vertical", 1)) + constraintList.append(Sketcher.Constraint("Vertical", 3)) doc.Sketch.addConstraint(constraintList) del constraintList body.addObject(doc.Sketch) - pocket = self.Doc.addObject('PartDesign::Pocket', 'Pocket') + pocket = self.Doc.addObject("PartDesign::Pocket", "Pocket") pocket.Refine = True pocket.Type = "Length" pocket.Length = 3 @@ -1626,9 +1804,13 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.Doc.recompute() volume3 = body.Shape.Volume # Change the filleted edges, potentially triggering TNP - fillet.Base = (box, ['Edge5', - 'Edge7', - ]) + fillet.Base = ( + box, + [ + "Edge5", + "Edge7", + ], + ) self.Doc.recompute() volume4 = body.Shape.Volume # Assert @@ -1687,42 +1869,65 @@ class TestTopologicalNamingProblem(unittest.TestCase): # # Add additional code to attach another sketch, then change the original sketch and check TNP def testPD_TNPSketchPadTouching(self): - """ Prove that a sketch with touching wires works correctly""" + """Prove that a sketch with touching wires works correctly""" doc = App.ActiveDocument - App.activeDocument().addObject('PartDesign::Body', 'Body') - doc.Body.newObject('Sketcher::SketchObject', 'Sketch') - doc.Sketch.AttachmentSupport = (doc.XY_Plane, ['']) - doc.Sketch.MapMode = 'FlatFace' + App.activeDocument().addObject("PartDesign::Body", "Body") + doc.Body.newObject("Sketcher::SketchObject", "Sketch") + doc.Sketch.AttachmentSupport = (doc.XY_Plane, [""]) + doc.Sketch.MapMode = "FlatFace" radius = 20 geoList = [] geoList.append( - Part.Circle(App.Vector(-20, 20, 0.000000), App.Vector(0.000000, 0.000000, 1.000000), - radius)) + Part.Circle( + App.Vector(-20, 20, 0.000000), + App.Vector(0.000000, 0.000000, 1.000000), + radius, + ) + ) doc.Sketch.addGeometry(geoList, False) geoList = [] geoList.append( - Part.Circle(App.Vector(20, 20, 0.000000), App.Vector(0.000000, 0.000000, 1.000000), - radius)) + Part.Circle( + App.Vector(20, 20, 0.000000), + App.Vector(0.000000, 0.000000, 1.000000), + radius, + ) + ) doc.Sketch.addGeometry(geoList, False) geoList = [] geoList.append( - Part.Circle(App.Vector(20, -20, 0.000000), App.Vector(0.000000, 0.000000, 1.000000), - radius)) + Part.Circle( + App.Vector(20, -20, 0.000000), + App.Vector(0.000000, 0.000000, 1.000000), + radius, + ) + ) doc.Sketch.addGeometry(geoList, False) geoList = [] geoList.append( - Part.Circle(App.Vector(-20, -20, 0.000000), App.Vector(0.000000, 0.000000, 1.000000), - radius)) + Part.Circle( + App.Vector(-20, -20, 0.000000), + App.Vector(0.000000, 0.000000, 1.000000), + radius, + ) + ) doc.Sketch.addGeometry(geoList, False) del geoList doc.recompute() - doc.Body.newObject('PartDesign::Pad', 'Pad') - doc.Pad.Profile = (doc.Sketch, ['', ]) + doc.Body.newObject("PartDesign::Pad", "Pad") + doc.Pad.Profile = ( + doc.Sketch, + [ + "", + ], + ) doc.Pad.Length = 10 - doc.Pad.ReferenceAxis = (doc.Sketch, ['N_Axis']) + doc.Pad.ReferenceAxis = (doc.Sketch, ["N_Axis"]) doc.Sketch.Visibility = False doc.recompute() - expected_volume = math.pi * radius * radius * 10 * 4 # Volume of 4 padded circles + expected_volume = ( + math.pi * radius * radius * 10 * 4 + ) # Volume of 4 padded circles # self.assertAlmostEqual(doc.Body.Shape.Volume, expected_volume ) # TODO ENABLE THIS ASSERTION WHEN IT PASSES # # Add additional code to attach another sketch, then change the original sketch and check TNP @@ -1764,12 +1969,12 @@ class TestTopologicalNamingProblem(unittest.TestCase): # # Add additional code to attach another sketch, then change the original sketch and check TNP def testPD_TNPSketchPadSketchMove(self): - """ Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has geometry move""" + """Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has geometry move""" doc = App.ActiveDocument - App.activeDocument().addObject('PartDesign::Body', 'Body') - doc.Body.newObject('Sketcher::SketchObject', 'Sketch') - doc.Sketch.AttachmentSupport = (doc.XY_Plane, ['']) - doc.Sketch.MapMode = 'FlatFace' + App.activeDocument().addObject("PartDesign::Body", "Body") + doc.Body.newObject("Sketcher::SketchObject", "Sketch") + doc.Sketch.AttachmentSupport = (doc.XY_Plane, [""]) + doc.Sketch.MapMode = "FlatFace" geoList = [] geoList.append(Part.LineSegment(App.Vector(0, 0, 0), App.Vector(40, 0, 0))) geoList.append(Part.LineSegment(App.Vector(40, 0, 0), App.Vector(40, 20, 0))) @@ -1777,26 +1982,31 @@ class TestTopologicalNamingProblem(unittest.TestCase): geoList.append(Part.LineSegment(App.Vector(0, 20, 0), App.Vector(0, 0, 0))) doc.Sketch.addGeometry(geoList, False) constraintList = [] - constraintList.append(Sketcher.Constraint('Coincident', 0, 2, 1, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 1, 2, 2, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 2, 2, 3, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 3, 2, 0, 1)) - constraintList.append(Sketcher.Constraint('Horizontal', 0)) - constraintList.append(Sketcher.Constraint('Horizontal', 2)) - constraintList.append(Sketcher.Constraint('Vertical', 1)) - constraintList.append(Sketcher.Constraint('Vertical', 3)) + constraintList.append(Sketcher.Constraint("Coincident", 0, 2, 1, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 1, 2, 2, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 2, 2, 3, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 3, 2, 0, 1)) + constraintList.append(Sketcher.Constraint("Horizontal", 0)) + constraintList.append(Sketcher.Constraint("Horizontal", 2)) + constraintList.append(Sketcher.Constraint("Vertical", 1)) + constraintList.append(Sketcher.Constraint("Vertical", 3)) doc.Sketch.addConstraint(constraintList) doc.recompute() - doc.Body.newObject('PartDesign::Pad', 'Pad') - doc.Pad.Profile = (doc.Sketch, ['', ]) + doc.Body.newObject("PartDesign::Pad", "Pad") + doc.Pad.Profile = ( + doc.Sketch, + [ + "", + ], + ) doc.Pad.Length = 10 - doc.Pad.ReferenceAxis = (doc.Sketch, ['N_Axis']) + doc.Pad.ReferenceAxis = (doc.Sketch, ["N_Axis"]) doc.Sketch.Visibility = False doc.Pad.Length = 10.000000 doc.Pad.TaperAngle = 0.000000 doc.Pad.UseCustomVector = 0 doc.Pad.Direction = (0, 0, 1) - doc.Pad.ReferenceAxis = (doc.Sketch, ['N_Axis']) + doc.Pad.ReferenceAxis = (doc.Sketch, ["N_Axis"]) doc.Pad.AlongSketchNormal = 1 doc.Pad.Type = 0 doc.Pad.UpToFace = None @@ -1805,9 +2015,14 @@ class TestTopologicalNamingProblem(unittest.TestCase): doc.Pad.Offset = 0 doc.recompute() doc.Sketch.Visibility = False - doc.Body.newObject('Sketcher::SketchObject', 'Sketch001') - doc.Sketch001.AttachmentSupport = (doc.Pad, ['Face6', ]) - doc.Sketch001.MapMode = 'FlatFace' + doc.Body.newObject("Sketcher::SketchObject", "Sketch001") + doc.Sketch001.AttachmentSupport = ( + doc.Pad, + [ + "Face6", + ], + ) + doc.Sketch001.MapMode = "FlatFace" geoList = [] geoList.append(Part.LineSegment(App.Vector(5, 5, 0), App.Vector(5, 10, 0))) geoList.append(Part.LineSegment(App.Vector(5, 10, 0), App.Vector(25, 10, 0))) @@ -1816,26 +2031,31 @@ class TestTopologicalNamingProblem(unittest.TestCase): doc.Sketch001.addGeometry(geoList, False) del geoList constraintList = [] - constraintList.append(Sketcher.Constraint('Coincident', 0, 2, 1, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 1, 2, 2, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 2, 2, 3, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 3, 2, 0, 1)) - constraintList.append(Sketcher.Constraint('Vertical', 0)) - constraintList.append(Sketcher.Constraint('Vertical', 2)) - constraintList.append(Sketcher.Constraint('Horizontal', 1)) - constraintList.append(Sketcher.Constraint('Horizontal', 3)) + constraintList.append(Sketcher.Constraint("Coincident", 0, 2, 1, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 1, 2, 2, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 2, 2, 3, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 3, 2, 0, 1)) + constraintList.append(Sketcher.Constraint("Vertical", 0)) + constraintList.append(Sketcher.Constraint("Vertical", 2)) + constraintList.append(Sketcher.Constraint("Horizontal", 1)) + constraintList.append(Sketcher.Constraint("Horizontal", 3)) doc.Sketch001.addConstraint(constraintList) doc.recompute() - doc.Body.newObject('PartDesign::Pad', 'Pad001') - doc.Pad001.Profile = (doc.Sketch001, ['', ]) + doc.Body.newObject("PartDesign::Pad", "Pad001") + doc.Pad001.Profile = ( + doc.Sketch001, + [ + "", + ], + ) doc.Pad001.Length = 10 - doc.Pad001.ReferenceAxis = (doc.Sketch001, ['N_Axis']) + doc.Pad001.ReferenceAxis = (doc.Sketch001, ["N_Axis"]) doc.Sketch001.Visibility = False doc.Pad001.Length = 10.000000 doc.Pad001.TaperAngle = 0.000000 doc.Pad001.UseCustomVector = 0 doc.Pad001.Direction = (0, 0, 1) - doc.Pad001.ReferenceAxis = (doc.Sketch001, ['N_Axis']) + doc.Pad001.ReferenceAxis = (doc.Sketch001, ["N_Axis"]) doc.Pad001.AlongSketchNormal = 1 doc.Pad001.Type = 0 doc.Pad001.UpToFace = None @@ -1857,29 +2077,39 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertTrue(doc.Sketch001.Placement.Matrix == matrix1) def testPD_TNPSketchPadSketchDelete(self): - """ Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has geometry deleted""" + """Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has geometry deleted""" doc = App.ActiveDocument - App.activeDocument().addObject('PartDesign::Body', 'Body') - doc.Body.newObject('Sketcher::SketchObject', 'Sketch') - doc.Sketch.AttachmentSupport = (doc.XY_Plane, ['']) - doc.Sketch.MapMode = 'FlatFace' + App.activeDocument().addObject("PartDesign::Body", "Body") + doc.Body.newObject("Sketcher::SketchObject", "Sketch") + doc.Sketch.AttachmentSupport = (doc.XY_Plane, [""]) + doc.Sketch.MapMode = "FlatFace" import ProfileLib.RegularPolygon - ProfileLib.RegularPolygon.makeRegularPolygon(doc.Sketch, 6, - App.Vector(0.000000, 0.000000, 0), - App.Vector(24, 12, 0), False) - doc.Sketch.addConstraint(Sketcher.Constraint('Coincident', 6, 3, -1, 1)) - doc.Sketch.addConstraint(Sketcher.Constraint('PointOnObject', 0, 2, -2)) + + ProfileLib.RegularPolygon.makeRegularPolygon( + doc.Sketch, + 6, + App.Vector(0.000000, 0.000000, 0), + App.Vector(24, 12, 0), + False, + ) + doc.Sketch.addConstraint(Sketcher.Constraint("Coincident", 6, 3, -1, 1)) + doc.Sketch.addConstraint(Sketcher.Constraint("PointOnObject", 0, 2, -2)) doc.recompute() - doc.Body.newObject('PartDesign::Pad', 'Pad') - doc.Pad.Profile = (doc.Sketch, ['', ]) + doc.Body.newObject("PartDesign::Pad", "Pad") + doc.Pad.Profile = ( + doc.Sketch, + [ + "", + ], + ) doc.Pad.Length = 10 - doc.Pad.ReferenceAxis = (doc.Sketch, ['N_Axis']) + doc.Pad.ReferenceAxis = (doc.Sketch, ["N_Axis"]) doc.Sketch.Visibility = False doc.Pad.Length = 10.000000 doc.Pad.TaperAngle = 0.000000 doc.Pad.UseCustomVector = 0 doc.Pad.Direction = (0, 0, 1) - doc.Pad.ReferenceAxis = (doc.Sketch, ['N_Axis']) + doc.Pad.ReferenceAxis = (doc.Sketch, ["N_Axis"]) doc.Pad.AlongSketchNormal = 1 doc.Pad.Type = 0 doc.Pad.UpToFace = None @@ -1888,38 +2118,56 @@ class TestTopologicalNamingProblem(unittest.TestCase): doc.Pad.Offset = 0 doc.recompute() doc.Sketch.Visibility = False - doc.Body.newObject('Sketcher::SketchObject', 'Sketch001') - doc.Sketch001.AttachmentSupport = (doc.Pad, ['Face8', ]) - doc.Sketch001.MapMode = 'FlatFace' + doc.Body.newObject("Sketcher::SketchObject", "Sketch001") + doc.Sketch001.AttachmentSupport = ( + doc.Pad, + [ + "Face8", + ], + ) + doc.Sketch001.MapMode = "FlatFace" geoList = [] - geoList.append(Part.LineSegment(App.Vector(-5, 5, 0.000000), App.Vector(-5, -5, 0.000000))) - geoList.append(Part.LineSegment(App.Vector(-5, -5, 0.000000), App.Vector(5, -5, 0.000000))) - geoList.append(Part.LineSegment(App.Vector(5, -5, 0.000000), App.Vector(5, 5, 0.000000))) - geoList.append(Part.LineSegment(App.Vector(5, 5, 0.000000), App.Vector(-5, 5, 0.000000))) + geoList.append( + Part.LineSegment(App.Vector(-5, 5, 0.000000), App.Vector(-5, -5, 0.000000)) + ) + geoList.append( + Part.LineSegment(App.Vector(-5, -5, 0.000000), App.Vector(5, -5, 0.000000)) + ) + geoList.append( + Part.LineSegment(App.Vector(5, -5, 0.000000), App.Vector(5, 5, 0.000000)) + ) + geoList.append( + Part.LineSegment(App.Vector(5, 5, 0.000000), App.Vector(-5, 5, 0.000000)) + ) doc.Sketch001.addGeometry(geoList, False) del geoList constraintList = [] - constraintList.append(Sketcher.Constraint('Coincident', 0, 2, 1, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 1, 2, 2, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 2, 2, 3, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 3, 2, 0, 1)) - constraintList.append(Sketcher.Constraint('Vertical', 0)) - constraintList.append(Sketcher.Constraint('Vertical', 2)) - constraintList.append(Sketcher.Constraint('Horizontal', 1)) - constraintList.append(Sketcher.Constraint('Horizontal', 3)) + constraintList.append(Sketcher.Constraint("Coincident", 0, 2, 1, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 1, 2, 2, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 2, 2, 3, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 3, 2, 0, 1)) + constraintList.append(Sketcher.Constraint("Vertical", 0)) + constraintList.append(Sketcher.Constraint("Vertical", 2)) + constraintList.append(Sketcher.Constraint("Horizontal", 1)) + constraintList.append(Sketcher.Constraint("Horizontal", 3)) doc.Sketch001.addConstraint(constraintList) constraintList = [] doc.recompute() - doc.Body.newObject('PartDesign::Pad', 'Pad001') - doc.Pad001.Profile = (doc.Sketch001, ['', ]) + doc.Body.newObject("PartDesign::Pad", "Pad001") + doc.Pad001.Profile = ( + doc.Sketch001, + [ + "", + ], + ) doc.Pad001.Length = 10 - doc.Pad001.ReferenceAxis = (doc.Sketch001, ['N_Axis']) + doc.Pad001.ReferenceAxis = (doc.Sketch001, ["N_Axis"]) doc.Sketch001.Visibility = False doc.Pad001.Length = 10.000000 doc.Pad001.TaperAngle = 0.000000 doc.Pad001.UseCustomVector = 0 doc.Pad001.Direction = (0, 0, 1) - doc.Pad001.ReferenceAxis = (doc.Sketch001, ['N_Axis']) + doc.Pad001.ReferenceAxis = (doc.Sketch001, ["N_Axis"]) doc.Pad001.AlongSketchNormal = 1 doc.Pad001.Type = 0 doc.Pad001.UpToFace = None @@ -1930,7 +2178,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): doc.Pad.Visibility = False doc.Sketch001.Visibility = False doc.Sketch.delGeometries([4]) - doc.Sketch.addConstraint(Sketcher.Constraint('Coincident', 3, 2, 4, 1)) + doc.Sketch.addConstraint(Sketcher.Constraint("Coincident", 3, 2, 4, 1)) doc.Sketch.delConstraint(12) doc.recompute() # If Sketch001 is still at the right start point, we are good. @@ -1940,43 +2188,43 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertTrue(doc.Sketch001.Placement.Matrix == matrix1) def testPD_TNPSketchPadSketchConstructionChange(self): - """ Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has geometry changed from Construction""" + """Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has geometry changed from Construction""" pass # TODO def testPD_TNPSketchPadSketchTrim(self): - """ Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has geometry trimmed""" + """Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has geometry trimmed""" pass # TODO def testPD_TNPSketchPadSketchExternal(self): - """ Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has external geometry changed""" + """Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has external geometry changed""" pass # TODO def testPD_TNPSketchPadSketchTransform(self): - """ Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has a transformation applied""" + """Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has a transformation applied""" pass # TODO def testPD_TNPSketchPadSketchSymmetry(self): - """ Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has Symmetry applied""" + """Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has Symmetry applied""" pass # TODO def testPD_TNPSketchPadSketchBSpline(self): - """ Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has BSpline changed""" + """Prove that a sketch attached to a padded sketch shape does not have a problem when the initial sketch has BSpline changed""" pass # TODO def testPD_TNPSketchRotSketchMove(self): - """ Prove that a sketch attached to a rotated sketch shape does not have a problem when the initial sketch has geometry moved""" + """Prove that a sketch attached to a rotated sketch shape does not have a problem when the initial sketch has geometry moved""" pass # TODO def testPD_TNPSketchPocketSketchMove(self): - """ Prove that a sketch attached to a pocketed sketch shape does not have a problem when the initial sketch has geometry moved""" + """Prove that a sketch attached to a pocketed sketch shape does not have a problem when the initial sketch has geometry moved""" pass # TODO def testPD_TNPSketchLoftSketchMove(self): - """ Prove that a sketch attached to a lofted sketch shape does not have a problem when the initial sketch has geometry moved""" + """Prove that a sketch attached to a lofted sketch shape does not have a problem when the initial sketch has geometry moved""" pass # TODO def testPD_TNPSketchPipeSketchMove(self): - """ Prove that a sketch attached to a piped sketch shape does not have a problem when the initial sketch has geometry moved""" + """Prove that a sketch attached to a piped sketch shape does not have a problem when the initial sketch has geometry moved""" pass # TODO def testSubelementNames(self): @@ -1994,17 +2242,23 @@ class TestTopologicalNamingProblem(unittest.TestCase): # Act App.Gui.Selection.addSelection("", extrude.Name, "Face2") # Assert - self.assertEqual(len(App.Gui.Selection.getSelectionEx("", 0)[0].SubElementNames), 1) + self.assertEqual( + len(App.Gui.Selection.getSelectionEx("", 0)[0].SubElementNames), 1 + ) if extrude.ElementMapVersion == "": # Should be '4' as of Mar 2023. - self.assertEqual(App.Gui.Selection.getSelectionEx("", 0)[0].SubElementNames[0], "Face2") + self.assertEqual( + App.Gui.Selection.getSelectionEx("", 0)[0].SubElementNames[0], "Face2" + ) else: - self.assertEqual(App.Gui.Selection.getSelectionEx("", 0)[0].SubElementNames[0][-8:], - ",F.Face2") + self.assertEqual( + App.Gui.Selection.getSelectionEx("", 0)[0].SubElementNames[0][-8:], + ",F.Face2", + ) def testGetElementFunctionality(self): # Arrange - body = self.Doc.addObject('PartDesign::Body', 'Body') - padSketch = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad') + body = self.Doc.addObject("PartDesign::Body", "Body") + padSketch = self.Doc.addObject("Sketcher::SketchObject", "SketchPad") pad = self.Doc.addObject("PartDesign::Pad", "Pad") body.addObject(padSketch) body.addObject(pad) @@ -2025,7 +2279,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): def testFileSaveRestore(self): # Arrange - self.Body = self.Doc.addObject('PartDesign::Body', 'Body') + self.Body = self.Doc.addObject("PartDesign::Body", "Body") self.create_t_sketch() self.assertEqual(self.Doc.Sketch.Shape.ElementMapSize, 18) filename = self.Doc.Name @@ -2046,19 +2300,22 @@ class TestTopologicalNamingProblem(unittest.TestCase): doc.ActiveObject.Label = "Cube" doc.addObject("Part::MultiFuse", "Fusion") doc.Fusion.Refine = False - doc.Fusion.Shapes = [doc.Box, doc.Box001, ] + doc.Fusion.Shapes = [ + doc.Box, + doc.Box001, + ] doc.recompute() self.assertEqual(doc.Fusion.Shape.ElementMapSize, 26) - doc.addObject('PartDesign::Body', 'Body') - doc.Body.Label = 'Body' + doc.addObject("PartDesign::Body", "Body") + doc.Body.Label = "Body" - doc.addObject('PartDesign::Body', 'Body001') - doc.Body001.Label = 'Body001' + doc.addObject("PartDesign::Body", "Body001") + doc.Body001.Label = "Body001" # act # Set up the subshapebinder version - binder = doc.Body.newObject('PartDesign::SubShapeBinder', 'Binder') + binder = doc.Body.newObject("PartDesign::SubShapeBinder", "Binder") binder.Support = [(doc.Fusion, (""))] doc.recompute() @@ -2067,14 +2324,19 @@ class TestTopologicalNamingProblem(unittest.TestCase): doc.recompute() # assert - self.assertEqual(doc.Body.OutList[1].Shape.ElementMapSize, - 26) # subobjects ( subshapebinder here ) should have elementmap - self.assertEqual(doc.Body.Shape.ElementMapSize, - 0) # TODO: This is Sus, although LS3 passes. Might be because + self.assertEqual( + doc.Body.OutList[1].Shape.ElementMapSize, 26 + ) # subobjects ( subshapebinder here ) should have elementmap + self.assertEqual( + doc.Body.Shape.ElementMapSize, 0 + ) # TODO: This is Sus, although LS3 passes. Might be because # SubShapeBinder is different in LS3. - self.assertEqual(doc.Body001.BaseFeature.Shape.ElementMapSize, - 26) # base feature lookup should have element map - self.assertEqual(doc.Body001.Shape.ElementMapSize, 26) # Body Shape should have element map + self.assertEqual( + doc.Body001.BaseFeature.Shape.ElementMapSize, 26 + ) # base feature lookup should have element map + self.assertEqual( + doc.Body001.Shape.ElementMapSize, 26 + ) # Body Shape should have element map def testBaseFeatureAttachmentSupport(self): # Arrange @@ -2084,48 +2346,65 @@ class TestTopologicalNamingProblem(unittest.TestCase): doc.recompute() doc.addObject("Part::Box", "Box") doc.ActiveObject.Label = "Cube" - doc.Box001.Placement = App.Placement(App.Vector(5.00, 5.00, 5.00), - App.Rotation(App.Vector(0.00, 0.00, 1.00), 0.00)) + doc.Box001.Placement = App.Placement( + App.Vector(5.00, 5.00, 5.00), + App.Rotation(App.Vector(0.00, 0.00, 1.00), 0.00), + ) doc.recompute() doc.addObject("Part::MultiFuse", "Fusion") doc.Fusion.Refine = False - doc.Fusion.Shapes = [doc.Box, doc.Box001, ] + doc.Fusion.Shapes = [ + doc.Box, + doc.Box001, + ] doc.recompute() # doc.Box.Visibility = False # doc.Box001.Visibility = False # doc.recompute() - doc.addObject('PartDesign::Body', 'Body') - doc.Body.Label = 'Body' + doc.addObject("PartDesign::Body", "Body") + doc.Body.Label = "Body" doc.Body.BaseFeature = App.activeDocument().Fusion doc.recompute() - doc.Body.newObject('Sketcher::SketchObject', 'Sketch') - doc.Sketch.AttachmentSupport = (doc.getObject('BaseFeature'), ('Face8')) - doc.Sketch.MapMode = 'FlatFace' + doc.Body.newObject("Sketcher::SketchObject", "Sketch") + doc.Sketch.AttachmentSupport = (doc.getObject("BaseFeature"), ("Face8")) + doc.Sketch.MapMode = "FlatFace" doc.recompute() geoList = [] geoList.append( - Part.LineSegment(App.Vector(12.0, 13.0, 0.000000), App.Vector(12.0, 11.0, 0.000000))) + Part.LineSegment( + App.Vector(12.0, 13.0, 0.000000), App.Vector(12.0, 11.0, 0.000000) + ) + ) geoList.append( - Part.LineSegment(App.Vector(12.0, 11, 0.000000), App.Vector(14.0, 11.0, 0.000000))) + Part.LineSegment( + App.Vector(12.0, 11, 0.000000), App.Vector(14.0, 11.0, 0.000000) + ) + ) geoList.append( - Part.LineSegment(App.Vector(14.0, 11, 0.000000), App.Vector(14.0, 13.0, 0.000000))) + Part.LineSegment( + App.Vector(14.0, 11, 0.000000), App.Vector(14.0, 13.0, 0.000000) + ) + ) geoList.append( - Part.LineSegment(App.Vector(14.0, 13.0, 0.000000), App.Vector(12, 13.0, 0.000000))) + Part.LineSegment( + App.Vector(14.0, 13.0, 0.000000), App.Vector(12, 13.0, 0.000000) + ) + ) doc.Sketch.addGeometry(geoList, False) del geoList constraintList = [] - constraintList.append(Sketcher.Constraint('Coincident', 0, 2, 1, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 1, 2, 2, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 2, 2, 3, 1)) - constraintList.append(Sketcher.Constraint('Coincident', 3, 2, 0, 1)) - constraintList.append(Sketcher.Constraint('Vertical', 0)) - constraintList.append(Sketcher.Constraint('Vertical', 2)) - constraintList.append(Sketcher.Constraint('Horizontal', 1)) - constraintList.append(Sketcher.Constraint('Horizontal', 3)) + constraintList.append(Sketcher.Constraint("Coincident", 0, 2, 1, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 1, 2, 2, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 2, 2, 3, 1)) + constraintList.append(Sketcher.Constraint("Coincident", 3, 2, 0, 1)) + constraintList.append(Sketcher.Constraint("Vertical", 0)) + constraintList.append(Sketcher.Constraint("Vertical", 2)) + constraintList.append(Sketcher.Constraint("Horizontal", 1)) + constraintList.append(Sketcher.Constraint("Horizontal", 3)) doc.Sketch.addConstraint(constraintList) del constraintList constraintList = [] @@ -2135,17 +2414,22 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertEqual(doc.Sketch.Shape.ElementMapSize, 12) # Arrange - doc.Body.newObject('PartDesign::Pad', 'Pad') - doc.Pad.Profile = (doc.Sketch, ['', ]) + doc.Body.newObject("PartDesign::Pad", "Pad") + doc.Pad.Profile = ( + doc.Sketch, + [ + "", + ], + ) doc.Pad.Length = 10 doc.recompute() - doc.Pad.ReferenceAxis = (doc.Sketch, ['N_Axis']) + doc.Pad.ReferenceAxis = (doc.Sketch, ["N_Axis"]) doc.Sketch.Visibility = False doc.Pad.Length = 10.000000 doc.Pad.TaperAngle = 0.000000 doc.Pad.UseCustomVector = 0 doc.Pad.Direction = (0, -1, 0) - doc.Pad.ReferenceAxis = (doc.Sketch, ['N_Axis']) + doc.Pad.ReferenceAxis = (doc.Sketch, ["N_Axis"]) doc.Pad.AlongSketchNormal = 1 doc.Pad.Type = 0 doc.Pad.UpToFace = None @@ -2157,44 +2441,51 @@ class TestTopologicalNamingProblem(unittest.TestCase): doc.recompute() # Act - doc.Box001.Width = '3.00 mm' - doc.Box001.Placement = App.Placement(App.Vector(5.00, 5.00, 5.00), - App.Rotation(App.Vector(0.00, 0.00, 1.00), 0.00)) + doc.Box001.Width = "3.00 mm" + doc.Box001.Placement = App.Placement( + App.Vector(5.00, 5.00, 5.00), + App.Rotation(App.Vector(0.00, 0.00, 1.00), 0.00), + ) doc.recompute() # Assert - self.assertEqual(len(doc.Body.Shape.Faces), 17) # Check that the object seems right. + self.assertEqual( + len(doc.Body.Shape.Faces), 17 + ) # Check that the object seems right. self.assertEqual(len(doc.Body.Shape.Edges), 42) self.assertEqual(len(doc.Body.Shape.Vertexes), 28) self.assertEqual(len(doc.Body.Shape.Shells), 1) self.assertEqual(len(doc.Body.Shape.Solids), 1) - self.assertEqual(doc.Sketch.AttachmentSupport[0][1][0], - 'Face9') # Attachment autochanged from Face8. + self.assertEqual( + doc.Sketch.AttachmentSupport[0][1][0], "Face9" + ) # Attachment autochanged from Face8. # potentially check the .BoundBox ( calc seems off on this, Not applying sketch position to Pad object ) def create_t_sketch(self): - self.Doc.getObject('Body').newObject('Sketcher::SketchObject', 'Sketch') + 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) + 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) + 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() @@ -2626,7 +2917,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertGreaterEqual(self.Body.Shape.Volume, 20126) def tearDown(self): - """ Clean up our test, optionally preserving the test document """ + """Clean up our test, optionally preserving the test document""" # This flag allows doing something like this: # App.KeepTestDoc = True # import TestApp