Salome HOME
1917b637f612b493cfe8e2d5d8c56b743a6660ad
[modules/shaper.git] / src / SketchPlugin / Test / TestProjectionEllipse.py
1 # Copyright (C) 2019-2022  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 SketchAPI import *
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 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
29 SketchCircle_1 = Sketch_1.addCircle(0, -100, 20)
30 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 20)
31 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
32 SketchLine_1 = SketchProjection_1.createdFeature()
33 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_1.result())
34 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchCircle_1.center(), SketchAPI_Line(SketchLine_1).startPoint(), 100, True)
35 model.do()
36 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOZ"), model.selection("EDGE", "PartSet/OX"), 30)
37 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), model.selection("FACE", "Plane_1"), 0, model.selection(), 0)
38 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
39 SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]"), True)
40 SketchCircle_2 = SketchProjection_2.createdFeature()
41 model.do()
42 Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
43 SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face]"), True)
44 SketchEllipse_1 = SketchProjection_3.createdFeature()
45 SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]"), True)
46 SketchEllipse_2 = SketchProjection_4.createdFeature()
47 model.do()
48 model.end()
49
50 from GeomAPI import *
51
52 circle = SketchCircle_2.results()[-1].resultSubShapePair()[0].shape()
53 assert(circle.isEdge() and circle.edge().isCircle())
54 ellipse1 = SketchEllipse_1.results()[-1].resultSubShapePair()[0].shape()
55 assert(ellipse1.isEdge() and ellipse1.edge().isEllipse())
56 ellipse2 = SketchEllipse_2.results()[-1].resultSubShapePair()[0].shape()
57 assert(ellipse2.isEdge() and ellipse2.edge().isEllipse())
58
59 assert(model.checkPythonDump())