Salome HOME
Debug of groups movement to the end for fillet feature unit-tests.
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupMove10.py
1 # -*- coding: utf-8 -*-
2
3 from salome.shaper import model
4 from ModelAPI import *
5
6 model.begin()
7 partSet = model.moduleDocument()
8 Part_1 = model.addPart(partSet)
9 Part_1_doc = Part_1.document()
10 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
11 SketchCircle_1 = Sketch_1.addCircle(-8, 20, 25)
12 SketchLine_1 = Sketch_1.addLine(40, 32, -5, 32)
13 SketchLine_2 = Sketch_1.addLine(-5, 32, -5, 5)
14 SketchLine_3 = Sketch_1.addLine(-5, 5, 40, 5)
15 SketchLine_4 = Sketch_1.addLine(40, 5, 40, 32)
16 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
17 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
18 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
19 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
20 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
21 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
22 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
23 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
24 model.do()
25 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
26 Group_1_objects = [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_3")]
27 Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
28 # to create groups of faces, edges and vertices
29 model.testHaveNamingSubshapes(Extrusion_1, model, Part_1_doc)
30 model.do()
31 Remove_SubShapes_1 = model.addRemoveSubShapes(Part_1_doc, model.selection("COMPSOLID", "Extrusion_1_1"))
32 Remove_SubShapes_1.setSubShapesToRemove([model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Extrusion_1_1_3")])
33 model.do()
34 # move groups to the end
35 LastFeature = Remove_SubShapes_1.feature()
36 for i in range(Part_1_doc.size("Groups")):
37   GroupFeature = Part_1_doc.feature(objectToResult(Part_1_doc.object("Groups", 0))) # move always the very first group
38   Part_1_doc.moveFeature(GroupFeature, LastFeature)
39   LastFeature = GroupFeature
40 model.end()
41
42 aFactory = ModelAPI_Session.get().validators()
43
44 # Check groups
45 a = 0
46 num_in_groups = [1, 10, 15, 7]
47 for i in range(Part_1_doc.size("Groups")):
48   GroupFeature = Part_1_doc.feature(objectToResult(Part_1_doc.object("Groups", i)))
49   assert(aFactory.validate(GroupFeature))
50   assert(GroupFeature.selectionList("group_list").size() == num_in_groups[a])
51   a = a + 1
52
53 assert(model.checkPythonDump())