Salome HOME
updated copyright message
[modules/shaper.git] / src / ParametersPlugin / Test / Test1806.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 """
21       Test1806.py
22       Unit test for testing the expression evaluation even no parameters are created
23
24 """
25 #=========================================================================
26 # Initialization of the test
27 #=========================================================================
28 from ModelAPI import *
29 from GeomDataAPI import *
30
31 __updated__ = "2016-11-23"
32
33 aSession = ModelAPI_Session.get()
34 aPartSet = aSession.moduleDocument()
35
36 #=========================================================================
37 # Create a part
38 #=========================================================================
39 aSession.startOperation()
40 aPartFeature = aPartSet.addFeature("Part")
41 aSession.finishOperation()
42
43 aPart = aSession.activeDocument()
44 #=========================================================================
45 # Create a sketch with a line and length
46 #=========================================================================
47 aSession.startOperation()
48 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
49 aXOYPlane = objectToResult(aPartSet.objectByName("Construction", "XOY"))
50 aSketchFeature.selection("External").setValue(aXOYPlane, None)
51 # Create lines
52 aLine = aSketchFeature.addFeature("SketchLine")
53 aStart = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
54 aStart.setValue(0, 0)
55 anEnd = geomDataAPI_Point2D(aLine.attribute("EndPoint"))
56 anEnd.setValue(200, 0)
57
58 aDistance = aSketchFeature.addFeature("SketchConstraintDistance")
59 aDistance.refattr("ConstraintEntityA").setAttr(aStart)
60 aDistance.refattr("ConstraintEntityB").setAttr(anEnd)
61 aDistance.real("ConstraintValue").setText("25/2")
62
63 aSession.finishOperation()
64
65 assert(aDistance.real("ConstraintValue").value() == 12.5)
66 #=========================================================================
67 # End of test
68 #=========================================================================
69 from salome.shaper import model
70 assert(model.checkPythonDump())