Salome HOME
d8b63d45879e7cb435ae13ff5e6955f1affcff9c
[modules/shaper.git] / src / SketchPlugin / Test / TestRemoveSketch.py
1 # Copyright (C) 2014-2022  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 """
21     TestRemoveSketch.py
22 """
23 from GeomDataAPI import *
24 from ModelAPI import *
25
26 #=========================================================================
27 # Initialization of the test
28 #=========================================================================
29 __updated__ = "2017-02-01"
30
31 aSession = ModelAPI_Session.get()
32 aDocument = aSession.moduleDocument()
33
34 # create a sketch
35 aSession.startOperation()
36 aSketchFeature = featureToCompositeFeature(aDocument.addFeature("Sketch"))
37 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
38 origin.setValue(0, 0, 0)
39 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
40 dirx.setValue(1, 0, 0)
41 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
42 norm.setValue(0, 0, 1)
43 aSession.finishOperation()
44
45 # create a line
46 aSession.startOperation()
47 aSketchLine = aSketchFeature.addFeature("SketchLine")
48 aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
49 aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
50 aLineStartPoint.setValue(50., 0.)
51 aLineEndPoint.setValue(100., 25.)
52 aSession.finishOperation()
53
54 # remove sketch
55 aSession.startOperation()
56 aDocument.removeFeature(aSketchFeature)
57 aSession.finishOperation()
58
59 #=========================================================================
60 # End of test
61 #=========================================================================