Salome HOME
updated copyright message
[modules/shaper.git] / src / FeaturesPlugin / Test / TestCopyMoveSubShapes.py
1 # Copyright (C) 2014-2023  CEA, EDF
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 # Checks selection of the sub-shapes move to the end with combination of 2 Copy features in history
21
22 from salome.shaper import model
23 from ModelAPI import *
24
25 model.begin()
26 partSet = model.moduleDocument()
27 Part_1 = model.addPart(partSet)
28 Part_1_doc = Part_1.document()
29 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
30 Group_1 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]")])
31 Copy_1 = model.addCopy(Part_1_doc, [model.selection("FACE", "Box_1_1/Front")], 2)
32 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), 0, 5, [model.selection("SOLID", "Box_1_1")])
33 Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Front"))
34 SketchCircle_1 = Sketch_1.addCircle(9.650212071680357, 9.344990586582618, 1.565166813054581)
35 ExtrusionCut_1.setNestedSketch(Sketch_1)
36 ExtrusionCut_1.result().setColor(225, 0, 0)
37 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1_1"))
38 SketchCircle_2 = Sketch_2.addCircle(0.7603686814133139, 9.06793355634084, 1.630854194501576)
39 model.do()
40 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2r")])
41 Cut_1 = model.addCut(Part_1_doc, [model.selection("FACE", "Box_1_1_1")], [model.selection("FACE", "Face_1_1")], keepSubResults = True)
42 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Box_1_1_2")], model.selection("EDGE", "PartSet/OX"), 5)
43 Copy_2 = model.addCopy(Part_1_doc, [model.selection("FACE", "Box_1_1_2")], 2)
44 Rotation_1 = model.addRotation(Part_1_doc, [model.selection("FACE", "Box_1_1_2_1")], model.selection("EDGE", "PartSet/OZ"), 10)
45 Rotation_2 = model.addRotation(Part_1_doc, [model.selection("FACE", "Box_1_1_2_2")], model.selection("EDGE", "PartSet/OZ"), 20)
46 model.do()
47 # move the group feature to the end - through 2 copies and many modifications of the selected edge
48 Part_1_doc.moveFeature(Group_1.feature(), Rotation_2.feature())
49 model.end()
50
51 # result is 5 edges: cut, translation, 2 rotations, extrusion cut
52 aFactory = ModelAPI_Session.get().validators()
53 assert(aFactory.validate(Group_1.feature()))
54 selectionList = Group_1.feature().selectionList("group_list")
55 assert(selectionList.size() == 5)
56
57 assert(model.checkPythonDump())