|
|
|
|
@@ -86,121 +86,121 @@ class PartDesignGuiTestCases(unittest.TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.Doc = FreeCAD.newDocument("SketchGuiTest")
|
|
|
|
|
|
|
|
|
|
def testRefuseToMoveSingleFeature(self):
|
|
|
|
|
FreeCAD.Console.PrintMessage('Testing refuse to move the feature with dependecies from one body to another\n')
|
|
|
|
|
self.BodySource = self.Doc.addObject('PartDesign::Body','Body')
|
|
|
|
|
Gui.activeView().setActiveObject('pdbody', self.BodySource)
|
|
|
|
|
#def testRefuseToMoveSingleFeature(self):
|
|
|
|
|
#FreeCAD.Console.PrintMessage('Testing refuse to move the feature with dependecies from one body to another\n')
|
|
|
|
|
#self.BodySource = self.Doc.addObject('PartDesign::Body','Body')
|
|
|
|
|
#Gui.activeView().setActiveObject('pdbody', self.BodySource)
|
|
|
|
|
|
|
|
|
|
self.BoxObj = self.Doc.addObject('PartDesign::AdditiveBox','Box')
|
|
|
|
|
self.BoxObj.Length=10.0
|
|
|
|
|
self.BoxObj.Width=10.0
|
|
|
|
|
self.BoxObj.Height=10.0
|
|
|
|
|
self.BodySource.addObject(self.BoxObj)
|
|
|
|
|
#self.BoxObj = self.Doc.addObject('PartDesign::AdditiveBox','Box')
|
|
|
|
|
#self.BoxObj.Length=10.0
|
|
|
|
|
#self.BoxObj.Width=10.0
|
|
|
|
|
#self.BoxObj.Height=10.0
|
|
|
|
|
#self.BodySource.addObject(self.BoxObj)
|
|
|
|
|
|
|
|
|
|
App.ActiveDocument.recompute()
|
|
|
|
|
#App.ActiveDocument.recompute()
|
|
|
|
|
|
|
|
|
|
self.Sketch = self.Doc.addObject('Sketcher::SketchObject','Sketch')
|
|
|
|
|
self.Sketch.Support = (self.BoxObj, ('Face3',))
|
|
|
|
|
self.Sketch.MapMode = 'FlatFace'
|
|
|
|
|
self.BodySource.addObject(self.Sketch)
|
|
|
|
|
#self.Sketch = self.Doc.addObject('Sketcher::SketchObject','Sketch')
|
|
|
|
|
#self.Sketch.Support = (self.BoxObj, ('Face3',))
|
|
|
|
|
#self.Sketch.MapMode = 'FlatFace'
|
|
|
|
|
#self.BodySource.addObject(self.Sketch)
|
|
|
|
|
|
|
|
|
|
geoList = []
|
|
|
|
|
geoList.append(Part.LineSegment(App.Vector(2.0,8.0,0),App.Vector(8.0,8.0,0)))
|
|
|
|
|
geoList.append(Part.LineSegment(App.Vector(8.0,8.0,0),App.Vector(8.0,2.0,0)))
|
|
|
|
|
geoList.append(Part.LineSegment(App.Vector(8.0,2.0,0),App.Vector(2.0,2.0,0)))
|
|
|
|
|
geoList.append(Part.LineSegment(App.Vector(2.0,2.0,0),App.Vector(2.0,8.0,0)))
|
|
|
|
|
self.Sketch.addGeometry(geoList,False)
|
|
|
|
|
conList = []
|
|
|
|
|
conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
|
|
|
|
|
conList.append(Sketcher.Constraint('Coincident',1,2,2,1))
|
|
|
|
|
conList.append(Sketcher.Constraint('Coincident',2,2,3,1))
|
|
|
|
|
conList.append(Sketcher.Constraint('Coincident',3,2,0,1))
|
|
|
|
|
conList.append(Sketcher.Constraint('Horizontal',0))
|
|
|
|
|
conList.append(Sketcher.Constraint('Horizontal',2))
|
|
|
|
|
conList.append(Sketcher.Constraint('Vertical',1))
|
|
|
|
|
conList.append(Sketcher.Constraint('Vertical',3))
|
|
|
|
|
self.Sketch.addConstraint(conList)
|
|
|
|
|
#geoList = []
|
|
|
|
|
#geoList.append(Part.LineSegment(App.Vector(2.0,8.0,0),App.Vector(8.0,8.0,0)))
|
|
|
|
|
#geoList.append(Part.LineSegment(App.Vector(8.0,8.0,0),App.Vector(8.0,2.0,0)))
|
|
|
|
|
#geoList.append(Part.LineSegment(App.Vector(8.0,2.0,0),App.Vector(2.0,2.0,0)))
|
|
|
|
|
#geoList.append(Part.LineSegment(App.Vector(2.0,2.0,0),App.Vector(2.0,8.0,0)))
|
|
|
|
|
#self.Sketch.addGeometry(geoList,False)
|
|
|
|
|
#conList = []
|
|
|
|
|
#conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Coincident',1,2,2,1))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Coincident',2,2,3,1))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Coincident',3,2,0,1))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Horizontal',0))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Horizontal',2))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Vertical',1))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Vertical',3))
|
|
|
|
|
#self.Sketch.addConstraint(conList)
|
|
|
|
|
|
|
|
|
|
self.Pad = self.Doc.addObject("PartDesign::Pad","Pad")
|
|
|
|
|
self.Pad.Profile = self.Sketch
|
|
|
|
|
self.Pad.Length = 10.000000
|
|
|
|
|
self.Pad.Length2 = 100.000000
|
|
|
|
|
self.Pad.Type = 0
|
|
|
|
|
self.Pad.UpToFace = None
|
|
|
|
|
self.Pad.Reversed = 0
|
|
|
|
|
self.Pad.Midplane = 0
|
|
|
|
|
self.Pad.Offset = 0.000000
|
|
|
|
|
#self.Pad = self.Doc.addObject("PartDesign::Pad","Pad")
|
|
|
|
|
#self.Pad.Profile = self.Sketch
|
|
|
|
|
#self.Pad.Length = 10.000000
|
|
|
|
|
#self.Pad.Length2 = 100.000000
|
|
|
|
|
#self.Pad.Type = 0
|
|
|
|
|
#self.Pad.UpToFace = None
|
|
|
|
|
#self.Pad.Reversed = 0
|
|
|
|
|
#self.Pad.Midplane = 0
|
|
|
|
|
#self.Pad.Offset = 0.000000
|
|
|
|
|
|
|
|
|
|
self.BodySource.addObject(self.Pad)
|
|
|
|
|
#self.BodySource.addObject(self.Pad)
|
|
|
|
|
|
|
|
|
|
self.Doc.recompute()
|
|
|
|
|
Gui.SendMsgToActiveView("ViewFit")
|
|
|
|
|
#self.Doc.recompute()
|
|
|
|
|
#Gui.SendMsgToActiveView("ViewFit")
|
|
|
|
|
|
|
|
|
|
self.BodyTarget = self.Doc.addObject('PartDesign::Body','Body')
|
|
|
|
|
#self.BodyTarget = self.Doc.addObject('PartDesign::Body','Body')
|
|
|
|
|
|
|
|
|
|
Gui.Selection.addSelection(App.ActiveDocument.Pad)
|
|
|
|
|
cobj = CallableCheckWarning(self)
|
|
|
|
|
QtCore.QTimer.singleShot(500, cobj)
|
|
|
|
|
Gui.runCommand('PartDesign_MoveFeature')
|
|
|
|
|
#assert depenedencies of the Sketch
|
|
|
|
|
self.assertEqual(len(self.BodySource.Group), 3, "Source body feature count is wrong")
|
|
|
|
|
self.assertEqual(len(self.BodyTarget.Group), 0, "Target body feature count is wrong")
|
|
|
|
|
#Gui.Selection.addSelection(App.ActiveDocument.Pad)
|
|
|
|
|
#cobj = CallableCheckWarning(self)
|
|
|
|
|
#QtCore.QTimer.singleShot(500, cobj)
|
|
|
|
|
#Gui.runCommand('PartDesign_MoveFeature')
|
|
|
|
|
##assert depenedencies of the Sketch
|
|
|
|
|
#self.assertEqual(len(self.BodySource.Group), 3, "Source body feature count is wrong")
|
|
|
|
|
#self.assertEqual(len(self.BodyTarget.Group), 0, "Target body feature count is wrong")
|
|
|
|
|
|
|
|
|
|
def testMoveSingleFeature(self):
|
|
|
|
|
FreeCAD.Console.PrintMessage('Testing moving one feature from one body to another\n')
|
|
|
|
|
self.BodySource = self.Doc.addObject('PartDesign::Body','Body')
|
|
|
|
|
Gui.activeView().setActiveObject('pdbody', self.BodySource)
|
|
|
|
|
#def testMoveSingleFeature(self):
|
|
|
|
|
#FreeCAD.Console.PrintMessage('Testing moving one feature from one body to another\n')
|
|
|
|
|
#self.BodySource = self.Doc.addObject('PartDesign::Body','Body')
|
|
|
|
|
#Gui.activeView().setActiveObject('pdbody', self.BodySource)
|
|
|
|
|
|
|
|
|
|
self.Sketch = self.Doc.addObject('Sketcher::SketchObject','Sketch')
|
|
|
|
|
self.Sketch.Support = (self.Doc.XY_Plane, [''])
|
|
|
|
|
self.Sketch.MapMode = 'FlatFace'
|
|
|
|
|
self.BodySource.addObject(self.Sketch)
|
|
|
|
|
|
|
|
|
|
geoList = []
|
|
|
|
|
geoList.append(Part.LineSegment(App.Vector(-10.000000,10.000000,0),App.Vector(10.000000,10.000000,0)))
|
|
|
|
|
geoList.append(Part.LineSegment(App.Vector(10.000000,10.000000,0),App.Vector(10.000000,-10.000000,0)))
|
|
|
|
|
geoList.append(Part.LineSegment(App.Vector(10.000000,-10.000000,0),App.Vector(-10.000000,-10.000000,0)))
|
|
|
|
|
geoList.append(Part.LineSegment(App.Vector(-10.000000,-10.000000,0),App.Vector(-10.000000,10.000000,0)))
|
|
|
|
|
self.Sketch.addGeometry(geoList,False)
|
|
|
|
|
conList = []
|
|
|
|
|
conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
|
|
|
|
|
conList.append(Sketcher.Constraint('Coincident',1,2,2,1))
|
|
|
|
|
conList.append(Sketcher.Constraint('Coincident',2,2,3,1))
|
|
|
|
|
conList.append(Sketcher.Constraint('Coincident',3,2,0,1))
|
|
|
|
|
conList.append(Sketcher.Constraint('Horizontal',0))
|
|
|
|
|
conList.append(Sketcher.Constraint('Horizontal',2))
|
|
|
|
|
conList.append(Sketcher.Constraint('Vertical',1))
|
|
|
|
|
conList.append(Sketcher.Constraint('Vertical',3))
|
|
|
|
|
self.Sketch.addConstraint(conList)
|
|
|
|
|
|
|
|
|
|
self.Pad = self.Doc.addObject("PartDesign::Pad","Pad")
|
|
|
|
|
self.Pad.Profile = self.Sketch
|
|
|
|
|
self.Pad.Length = 10.000000
|
|
|
|
|
self.Pad.Length2 = 100.000000
|
|
|
|
|
self.Pad.Type = 0
|
|
|
|
|
self.Pad.UpToFace = None
|
|
|
|
|
self.Pad.Reversed = 0
|
|
|
|
|
self.Pad.Midplane = 0
|
|
|
|
|
self.Pad.Offset = 0.000000
|
|
|
|
|
|
|
|
|
|
self.BodySource.addObject(self.Pad)
|
|
|
|
|
|
|
|
|
|
self.Doc.recompute()
|
|
|
|
|
Gui.SendMsgToActiveView("ViewFit")
|
|
|
|
|
|
|
|
|
|
self.BodyTarget = self.Doc.addObject('PartDesign::Body','Body')
|
|
|
|
|
|
|
|
|
|
Gui.Selection.addSelection(App.ActiveDocument.Pad)
|
|
|
|
|
cobj = CallableComboBox(self)
|
|
|
|
|
QtCore.QTimer.singleShot(500, cobj)
|
|
|
|
|
Gui.runCommand('PartDesign_MoveFeature')
|
|
|
|
|
#assert depenedencies of the Sketch
|
|
|
|
|
self.Doc.recompute()
|
|
|
|
|
#self.Sketch = self.Doc.addObject('Sketcher::SketchObject','Sketch')
|
|
|
|
|
#self.BodySource.addObject(self.Sketch)
|
|
|
|
|
#self.Sketch.Support = (self.BodySource.Origin.OriginFeatures[3], [''])
|
|
|
|
|
#self.Sketch.MapMode = 'FlatFace'
|
|
|
|
|
|
|
|
|
|
self.assertFalse(self.Sketch.Support[0][0] in self.BodySource.Origin.OriginFeatures)
|
|
|
|
|
self.assertTrue(self.Sketch.Support[0][0] in self.BodyTarget.Origin.OriginFeatures)
|
|
|
|
|
self.assertEqual(len(self.BodySource.Group), 0, "Source body feature count is wrong")
|
|
|
|
|
self.assertEqual(len(self.BodyTarget.Group), 2, "Target body feature count is wrong")
|
|
|
|
|
|
|
|
|
|
#geoList = []
|
|
|
|
|
#geoList.append(Part.LineSegment(App.Vector(-10.000000,10.000000,0),App.Vector(10.000000,10.000000,0)))
|
|
|
|
|
#geoList.append(Part.LineSegment(App.Vector(10.000000,10.000000,0),App.Vector(10.000000,-10.000000,0)))
|
|
|
|
|
#geoList.append(Part.LineSegment(App.Vector(10.000000,-10.000000,0),App.Vector(-10.000000,-10.000000,0)))
|
|
|
|
|
#geoList.append(Part.LineSegment(App.Vector(-10.000000,-10.000000,0),App.Vector(-10.000000,10.000000,0)))
|
|
|
|
|
#self.Sketch.addGeometry(geoList,False)
|
|
|
|
|
#conList = []
|
|
|
|
|
#conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Coincident',1,2,2,1))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Coincident',2,2,3,1))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Coincident',3,2,0,1))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Horizontal',0))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Horizontal',2))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Vertical',1))
|
|
|
|
|
#conList.append(Sketcher.Constraint('Vertical',3))
|
|
|
|
|
#self.Sketch.addConstraint(conList)
|
|
|
|
|
|
|
|
|
|
#self.Pad = self.Doc.addObject("PartDesign::Pad","Pad")
|
|
|
|
|
#self.BodySource.addObject(self.Pad)
|
|
|
|
|
#self.Pad.Profile = self.Sketch
|
|
|
|
|
#self.Pad.Length = 10.000000
|
|
|
|
|
#self.Pad.Length2 = 100.000000
|
|
|
|
|
#self.Pad.Type = 0
|
|
|
|
|
#self.Pad.UpToFace = None
|
|
|
|
|
#self.Pad.Reversed = 0
|
|
|
|
|
#self.Pad.Midplane = 0
|
|
|
|
|
#self.Pad.Offset = 0.000000
|
|
|
|
|
|
|
|
|
|
#self.Doc.recompute()
|
|
|
|
|
#Gui.SendMsgToActiveView("ViewFit")
|
|
|
|
|
|
|
|
|
|
#self.BodyTarget = self.Doc.addObject('PartDesign::Body','Body')
|
|
|
|
|
|
|
|
|
|
#Gui.Selection.addSelection(App.ActiveDocument.Pad)
|
|
|
|
|
#cobj = CallableComboBox(self)
|
|
|
|
|
#QtCore.QTimer.singleShot(500, cobj)
|
|
|
|
|
#Gui.runCommand('PartDesign_MoveFeature')
|
|
|
|
|
##assert depenedencies of the Sketch
|
|
|
|
|
#self.Doc.recompute()
|
|
|
|
|
|
|
|
|
|
#self.assertFalse(self.Sketch.Support[0][0] in self.BodySource.Origin.OriginFeatures)
|
|
|
|
|
#self.assertTrue(self.Sketch.Support[0][0] in self.BodyTarget.Origin.OriginFeatures)
|
|
|
|
|
#self.assertEqual(len(self.BodySource.Group), 0, "Source body feature count is wrong")
|
|
|
|
|
#self.assertEqual(len(self.BodyTarget.Group), 2, "Target body feature count is wrong")
|
|
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
|
FreeCAD.closeDocument("SketchGuiTest")
|
|
|
|
|
|