Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / SketchPlugin / Test / Test2273.py
1 ## Copyright (C) 2014-2017  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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 """
22     Test2273.py
23     Test case for issue #2273 "Error when reading HDF and Python dump"
24                               (multi-rotation center refers to a feature produced by itself)
25 """
26
27 from salome.shaper import model
28 from SketchAPI import *
29
30 model.begin()
31 partSet = model.moduleDocument()
32 Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
33 SketchLine_1 = Sketch_1.addLine(-65.36884900412264, 10.74954405845571, -18.59380593895045, 62.75409504395774)
34 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "Origin"), False)
35 SketchPoint_1 = SketchProjection_1.createdFeature()
36
37
38 # Test 1. Check MultiRotation error
39
40 SketchMultiRotation_1 = Sketch_1.addRotation([SketchLine_1.result()], SketchAPI_Point(SketchPoint_1).coordinates(), 90, 3)
41 [SketchLine_2, SketchLine_3] = SketchMultiRotation_1.rotated()
42 model.do()
43 # check MultiRotation has NO error
44 assert(SketchMultiRotation_1.feature().error() == "")
45 # change center of MultiRotation to extremity of generated feature, check an error appears
46 SketchMultiRotation_1.center().setAttr(SketchAPI_Line(SketchLine_2).startPoint())
47 model.do()
48 assert(SketchMultiRotation_1.feature().error() != "")
49 # revert changes => no error
50 SketchMultiRotation_1.center().setAttr(SketchAPI_Point(SketchPoint_1).coordinates())
51 model.do()
52 assert(SketchMultiRotation_1.feature().error() == "")
53
54
55 # Test 2. Check MultiRotation error
56
57 SketchMultiTranslation_1 = Sketch_1.addTranslation([SketchLine_1.result()], SketchLine_1.startPoint(), SketchAPI_Line(SketchLine_2).endPoint(), 2)
58 [SketchLine_4] = SketchMultiTranslation_1.translated()
59 model.do()
60 # check MultiTranslation has NO error
61 assert(SketchMultiTranslation_1.feature().error() == "")
62 # change start point to extremity of generated feature, check an error appears
63 SketchMultiTranslation_1.startPoint().setAttr(SketchAPI_Line(SketchLine_4).endPoint())
64 model.do()
65 assert(SketchMultiTranslation_1.feature().error() != "")
66 # revert changes => no error
67 SketchMultiTranslation_1.startPoint().setAttr(SketchLine_1.startPoint())
68 model.do()
69 assert(SketchMultiTranslation_1.feature().error() == "")
70 # change end point to extremity of generated feature, check an error appears
71 SketchMultiTranslation_1.endPoint().setAttr(SketchAPI_Line(SketchLine_4).endPoint())
72 model.do()
73 assert(SketchMultiTranslation_1.feature().error() != "")
74 # revert changes => no error
75 SketchMultiTranslation_1.endPoint().setAttr(SketchAPI_Line(SketchLine_2).endPoint())
76 model.do()
77 assert(SketchMultiTranslation_1.feature().error() == "")
78
79
80 # Test 3. Check Mirror error
81
82 SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_2.result(), [SketchLine_1.result(), SketchLine_3.result()])
83 [SketchLine_5, SketchLine_6] = SketchConstraintMirror_1.mirrored()
84 model.do()
85 # check Mirror has NO error
86 assert(SketchConstraintMirror_1.feature().error() == "")
87 # change mirror line to generated feature, check an error appears
88 SketchConstraintMirror_1.mirrorLine().setObject(SketchLine_5.feature().firstResult())
89 model.do()
90 assert(SketchConstraintMirror_1.feature().error() != "")
91 # revert changes => no error
92 SketchConstraintMirror_1.mirrorLine().setObject(SketchLine_2.feature().firstResult())
93 model.do()
94 assert(SketchConstraintMirror_1.feature().error() == "")
95
96 model.end()
97
98
99 assert(model.checkPythonDump())