Test for changed Sketches avoiding TNP
This commit is contained in:
@@ -789,6 +789,97 @@ class TestTopologicalNamingProblem(unittest.TestCase):
|
||||
self.assertEqual(plane.Shape.ElementMapSize, 0)
|
||||
self.assertEqual(pad.Shape.ElementMapSize, 26)
|
||||
|
||||
def testChangeSketch(self):
|
||||
# Arrange
|
||||
self.Body = self.Doc.addObject('PartDesign::Body', 'Body')
|
||||
# Make first offset cube Pad
|
||||
self.PadSketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch')
|
||||
self.Body.addObject(self.PadSketch)
|
||||
TestSketcherApp.CreateRectangleSketch(self.PadSketch, (0, 0), (31.37, 25.2))
|
||||
self.Doc.recompute()
|
||||
self.Pad = self.Doc.addObject("PartDesign::Pad", "Pad")
|
||||
self.Body.addObject(self.Pad)
|
||||
self.Pad.Profile = self.PadSketch
|
||||
self.Pad.Length = 10
|
||||
self.Doc.recompute()
|
||||
|
||||
self.Sketch001 = self.Body.newObject('Sketcher::SketchObject','Sketch001')
|
||||
self.Sketch001.AttachmentSupport = (self.Doc.getObject('Pad'),['Face6',])
|
||||
self.Sketch001.MapMode = 'FlatFace'
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
self.Sketch001.addExternal("Pad","Edge10")
|
||||
self.Sketch001.addExternal("Pad","Edge7")
|
||||
|
||||
geoList = []
|
||||
geoList.append(Part.Circle(App.Vector(15.093666, 13.036922, 0.000000),
|
||||
App.Vector(0.000000, 0.000000, 1.000000), 5.000000))
|
||||
self.Sketch001.addGeometry(geoList,False)
|
||||
del geoList
|
||||
self.Sketch001.addConstraint(Sketcher.Constraint('Radius',0,5.000000))
|
||||
self.Sketch001.addConstraint(Sketcher.Constraint('Symmetric',-3,2,-4,1,0,3))
|
||||
App.ActiveDocument.recompute()
|
||||
self.Doc.recompute()
|
||||
|
||||
self.Pad001 = self.Body.newObject('PartDesign::Pad','Pad001')
|
||||
self.Pad001.Profile = self.Doc.getObject('Sketch001')
|
||||
self.Pad001.Length = 10
|
||||
App.ActiveDocument.recompute()
|
||||
self.Pad001.ReferenceAxis = (self.Doc.getObject('Sketch001'),['N_Axis'])
|
||||
self.Sketch001.Visibility = False
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
self.Pad001.Length = 10.000000
|
||||
self.Pad001.TaperAngle = 0.000000
|
||||
self.Pad001.UseCustomVector = 0
|
||||
self.Pad001.Direction = (0, 0, 1)
|
||||
self.Pad001.ReferenceAxis = (self.Doc.getObject('Sketch001'), ['N_Axis'])
|
||||
self.Pad001.AlongSketchNormal = 1
|
||||
self.Pad001.Type = 0
|
||||
self.Pad001.UpToFace = None
|
||||
self.Pad001.Reversed = 0
|
||||
self.Pad001.Midplane = 0
|
||||
self.Pad001.Offset = 0
|
||||
self.Doc.recompute()
|
||||
self.Doc.getObject('Pad').Visibility = False
|
||||
|
||||
self.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)))
|
||||
self.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))
|
||||
self.PadSketch.addConstraint(constraintList)
|
||||
del constraintList
|
||||
self.Doc.recompute()
|
||||
# Assert
|
||||
if self.Body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023.
|
||||
return
|
||||
self.assertEqual(self.Body.Shape.BoundBox.XMin,0)
|
||||
self.assertEqual(self.Body.Shape.BoundBox.YMin,0)
|
||||
self.assertEqual(self.Body.Shape.BoundBox.ZMin,0)
|
||||
self.assertEqual(self.Body.Shape.BoundBox.XMax,31.37)
|
||||
self.assertEqual(self.Body.Shape.BoundBox.YMax,25.2)
|
||||
self.assertEqual(self.Body.Shape.BoundBox.ZMax,20)
|
||||
|
||||
def create_t_sketch(self):
|
||||
self.Doc.getObject('Body').newObject('Sketcher::SketchObject', 'Sketch')
|
||||
geo_list = [
|
||||
@@ -818,4 +909,5 @@ class TestTopologicalNamingProblem(unittest.TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
""" Close our test document """
|
||||
App.closeDocument("PartDesignTestTNP")
|
||||
# App.closeDocument("PartDesignTestTNP")
|
||||
pass
|
||||
Reference in New Issue
Block a user