Salome HOME
fe65cef53783a2bfd8f3e70b8b171ccf5196bd64
[modules/shaper.git] / src / FeaturesPlugin / Test / Test22847.py
1 # Copyright (C) 2020-2023  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 from salome.shaper import model
21
22 model.begin()
23 partSet = model.moduleDocument()
24
25 ### Create Part
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
29 SketchLine_1 = Sketch_1.addLine(22, 23, 60, 70)
30 SketchLine_2 = Sketch_1.addLine(60, 70, 90, 23)
31 Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
32 SketchLine_3 = Sketch_1.addLine(90, 23, 22, 23)
33 Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
34 Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint())
35 Sketch_1.setHorizontal(SketchLine_3.result())
36 SketchLine_4 = Sketch_1.addLine(60, 72, 54, 23)
37 Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_3.result())
38 Sketch_1.setCoincident(SketchLine_4.startPoint(), SketchLine_2.startPoint())
39 model.do()
40
41 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection(), 10, 0, "Faces|Wires")
42 LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OY"), 60, 2, model.selection("EDGE", "PartSet/OX"), 75, 2, keepSubResults = True)
43
44 ### Create Group
45 Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "LinearCopy_1_1_1_2/MF:Translated&Sketch_1/SketchLine_2")])
46
47 ### Create Remove_SubShapes
48 Remove_SubShapes_1 = model.addRemoveSubShapes(Part_1_doc, model.selection("COMPOUND", "LinearCopy_1_1"))
49 Remove_SubShapes_1.setSubShapesToRemove([model.selection("SOLID", "LinearCopy_1_1_4_2")])
50 model.end()
51
52 # Move the group to the end of history
53 model.begin()
54 Part_1_doc.moveFeature(Group_1.feature(), Remove_SubShapes_1.feature())
55 model.end()
56
57 # check that all groups are correct
58 from ModelAPI import *
59 aFactory = ModelAPI_Session.get().validators()
60
61 assert(aFactory.validate(Group_1.feature()))
62 assert(Group_1.groupList().size() == 1)
63 assert(Group_1.groupList().value(0).value().shapeTypeStr() == "FACE")
64 assert(len(Group_1.groupList().value(0).namingName()) > 0)
65
66 assert(model.checkPythonDump())