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