1 # Copyright (C) 2014-2020 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # The test for correct selection of a whole feautre as argument of other feature: select all extrusions
21 # produced from the scetch, then change the number of sketch contours, so, anytway all extrusions must
22 # still be selected in the Cut Boolean oepration
24 from SketchAPI import *
26 from salome.shaper import model
29 partSet = model.moduleDocument()
30 Part_1 = model.addPart(partSet)
31 Part_1_doc = Part_1.document()
32 Param_N = model.addParameter(Part_1_doc, "n", "3")
33 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
34 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
35 SketchLine_1 = SketchProjection_1.createdFeature()
36 SketchCircle_1 = Sketch_1.addCircle(30, 0, 15)
37 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_1.center())
38 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchCircle_1.center(), 30, True)
39 SketchMultiRotation_1 = Sketch_1.addRotation([SketchCircle_1.results()[1]], SketchAPI_Line(SketchLine_1).startPoint(), 360, "n=", True)
40 [SketchCircle_2, SketchCircle_3] = SketchMultiRotation_1.rotated()
41 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 15)
43 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
44 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOZ"))
45 SketchCircle_4 = Sketch_2.addCircle(25, 5, 4)
46 SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_4.results()[1], 4)
47 SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX"), False)
48 SketchLine_2 = SketchProjection_2.createdFeature()
49 SketchConstraintDistance_2 = Sketch_2.setDistance(SketchLine_2.result(), SketchCircle_4.center(), 5, True)
50 SketchConstraintDistanceHorizontal_1 = Sketch_2.setHorizontalDistance(SketchAPI_Line(SketchLine_2).startPoint(), SketchCircle_4.center(), 25)
52 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2r")], model.selection("EDGE", "PartSet/OZ"), 360, 0)
53 Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1")], [model.selection("COMPOUND", "all-in-Revolution_1")])
56 # update the parameter N => number of sketch contours is changed
60 assert(Cut_1.result().numberOfSubs() == 4)
62 assert(model.checkPythonDump())