Salome HOME
Fixed ModelAPI tests.
[modules/shaper.git] / src / ModelAPI / Test / TestFeatureSelection_2.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 # The test for correct selection of a whole feautre as argument of other feature: select all extrusions
22 # produced from the scetch, then change the number of sketch contours, so, anytway all extrusions must
23 # still be selected in the Cut Boolean oepration
24
25 from SketchAPI import *
26
27 from salome.shaper import model
28
29 model.begin()
30 partSet = model.moduleDocument()
31 Part_1 = model.addPart(partSet)
32 Part_1_doc = Part_1.document()
33 Param_N = model.addParameter(Part_1_doc, "n", "3")
34 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
35 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
36 SketchLine_1 = SketchProjection_1.createdFeature()
37 SketchCircle_1 = Sketch_1.addCircle(30, 0, 15)
38 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_1.center())
39 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchCircle_1.center(), 30, True)
40 SketchMultiRotation_1 = Sketch_1.addRotation([SketchCircle_1.results()[1]], SketchAPI_Line(SketchLine_1).startPoint(), 360, "n=", True)
41 [SketchCircle_2, SketchCircle_3] = SketchMultiRotation_1.rotated()
42 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 15)
43 model.do()
44 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
45 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOZ"))
46 SketchCircle_4 = Sketch_2.addCircle(25, 5, 4)
47 SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_4.results()[1], 4)
48 SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX"), False)
49 SketchLine_2 = SketchProjection_2.createdFeature()
50 SketchConstraintDistance_2 = Sketch_2.setDistance(SketchLine_2.result(), SketchCircle_4.center(), 5, True)
51 SketchConstraintDistanceHorizontal_1 = Sketch_2.setHorizontalDistance(SketchAPI_Line(SketchLine_2).startPoint(), SketchCircle_4.center(), 25)
52 model.do()
53 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2r")], model.selection("EDGE", "PartSet/OZ"), 360, 0)
54 Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1")], [model.selection("COMPOUND", "all-in-Revolution_1")])
55 model.do()
56
57 # update the parameter N => number of sketch contours is changed
58 Param_N.setValue(4)
59 Part_1_doc.setCurrentFeature(Cut_1.feature(), False)
60 model.end()
61
62 assert(Cut_1.result().numberOfSubs() == 4)
63
64 assert(model.checkPythonDump())