1 ## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 # Created a Part Remove/Duplicate API functionality since from low level and python dump it is not
22 # tested: feature history infor is not stored.
24 from salome.shaper import model
26 # prepare axis created by PartSet and Part points
28 PartSet = model.moduleDocument()
29 Part_1 = model.addPart(PartSet)
30 Part_1_doc = Part_1.document()
31 Point_2 = model.addPoint(Part_1_doc, 100, 50, 20)
32 Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("VERTEX", "Point_1"))
35 # Duplicate this part twice, duplicate the first Copy also
36 Copy_1 = model.duplicatePart(Part_1)
37 Copy_2 = model.duplicatePart(Part_1)
38 Copy_3 = model.duplicatePart(Copy_1)
41 # check the intermediate result
42 assert PartSet.size("Parts") == 4
44 for n in ["Part_1", "Part_3", "Part_2", "Part_4"]:
45 assert PartSet.object("Parts", i).data().name() == n
48 # Remove the middle Part
49 model.removePart(Copy_2)
50 # move the history line to the end, because remove makes the current feature up
51 PartSet.setCurrentFeature(Copy_3.feature(), False)
54 # check the intermediate result
55 assert PartSet.size("Parts") == 3
57 for n in ["Part_1", "Part_2", "Part_4"]:
58 assert PartSet.object("Parts", i).data().name() == n
62 model.removePart(Copy_1)
63 # move the history line to the end, because remove makes the current feature up
64 PartSet.setCurrentFeature(Copy_3.feature(), False)
67 # Undo the last remove
71 assert PartSet.size("Parts") == 3
73 for n in ["Part_1", "Part_2", "Part_4"]:
74 assert PartSet.object("Parts", i).data().name() == n