Salome HOME
Fix the problem of the sketch plane update
[modules/shaper.git] / src / SketchPlugin / Test / TestUpdateSketch.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 # -*- coding: utf-8 -*-
21
22 from salome.shaper import model
23
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 ParamA = model.addParameter(Part_1_doc, "a", "200")
29 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
30 SketchLine_1 = Sketch_1.addLine(19.66215729983772, 107.3479424462301, -0.3378427001622813, 107.3479424462301)
31 SketchLine_2 = Sketch_1.addLine(-0.3378427001622813, 107.3479424462301, -0.3378427001622813, 467.3479424462301)
32 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
33 SketchLine_3 = Sketch_1.addLine(-0.3378427001622813, 467.3479424462301, 49.66215729983772, 467.3479424462301)
34 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
35 SketchLine_4 = Sketch_1.addLine(-0.3378427001622813, 307.3479424462301, 29.66215729983772, 307.3479424462301)
36 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_4.startPoint(), SketchLine_2.result())
37 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
38 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_4.result())
39 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_1.result())
40 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
41 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 50)
42 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_4.result(), 30)
43 SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_1.result(), 20)
44 SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchLine_1.endPoint(), SketchLine_4.startPoint(), "a")
45 SketchConstraintDistanceVertical_2 = Sketch_1.setVerticalDistance(SketchLine_4.startPoint(), SketchLine_2.endPoint(), "a*0.8")
46 model.do()
47 Edge_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_1")]
48 Edge_1 = model.addEdge(Part_1_doc, Edge_1_objects)
49 Revolution_1_objects = [model.selection("EDGE", "Edge_1_1"), model.selection("EDGE", "Edge_1_2"), model.selection("EDGE", "Edge_1_3")]
50 Revolution_1 = model.addRevolution(Part_1_doc, Revolution_1_objects, model.selection("EDGE", "Sketch_1/SketchLine_2"), 360, 0)
51 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_2"))
52 SketchCircle_1 = Sketch_2.addCircle(-8.007012574805483, 5.997620437244276, 8.148502128958617)
53 model.do()
54 # change the height of the second sketch plane
55 ParamA.setValue(50)
56 model.end()
57 # check that the second sketch result is recomputed: is located in the same plane as base
58 referenceY = Sketch_2.feature().selection("External").value().middlePoint().y()
59 resultY = Sketch_2.feature().results()[0].shape().middlePoint().y()
60 assert(referenceY == resultY)