1 # Copyright (C) 2014-2023 CEA, EDF
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Created a Part Remove/Duplicate API functionality since from low level and python dump it is not
21 # tested: feature history infor is not stored.
23 from salome.shaper import model
25 # prepare axis created by PartSet and Part points
27 PartSet = model.moduleDocument()
28 Part_1 = model.addPart(PartSet)
29 Part_1_doc = Part_1.document()
30 Point_2 = model.addPoint(Part_1_doc, 100, 50, 20)
31 Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("VERTEX", "Point_1"))
34 # Duplicate this part twice, duplicate the first Copy also
35 Copy_1 = model.duplicatePart(Part_1)
36 Copy_2 = model.duplicatePart(Part_1)
37 Copy_3 = model.duplicatePart(Copy_1)
40 # check the intermediate result
41 assert PartSet.size("Parts") == 4
43 for n in ["Part_1", "Part_3", "Part_2", "Part_4"]:
44 assert PartSet.object("Parts", i).data().name() == n
47 # Remove the middle Part
48 model.removePart(Copy_2)
49 # move the history line to the end, because remove makes the current feature up
50 PartSet.setCurrentFeature(Copy_3.feature(), False)
53 # check the intermediate result
54 assert PartSet.size("Parts") == 3
56 for n in ["Part_1", "Part_2", "Part_4"]:
57 assert PartSet.object("Parts", i).data().name() == n
61 model.removePart(Copy_1)
62 # move the history line to the end, because remove makes the current feature up
63 PartSet.setCurrentFeature(Copy_3.feature(), False)
66 # Undo the last remove
70 assert PartSet.size("Parts") == 3
72 for n in ["Part_1", "Part_2", "Part_4"]:
73 assert PartSet.object("Parts", i).data().name() == n