]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/Test/Test2228.py
Salome HOME
Issue #19058: Error in sketch projection when changing parameter
[modules/shaper.git] / src / ModelAPI / Test / Test2228.py
1 # Copyright (C) 2014-2020  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 Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
25 SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "Origin"))
26 SketchCircle_1 = Sketch_1.addCircle(0, 0, 0.3529019640553777)
27 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center())
28 SketchCircle_2 = Sketch_1.addCircle(0, 0, 0.4492388920251514)
29 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchCircle_2.center())
30 model.do()
31 Part_1 = model.addPart(partSet)
32 Part_1_doc = Part_1.document()
33 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1/Face-SketchCircle_2_2f-SketchCircle_1_2r")], model.selection(), 5, 0)
34 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ"))
35 SketchCircle_3 = Sketch_2.addCircle(-0.01730125245914903, 1.175069067120482, 0.2787321880802174)
36 SketchCircle_4 = Sketch_2.addCircle(-0.01730125245914903, 1.175069067120482, 0.3197841740766353)
37 SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchCircle_3.center(), SketchCircle_4.center())
38 model.do()
39 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f-SketchCircle_1_2r")], model.selection(), 0, 3)
40 Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1/Face-SketchCircle_1_2f")], model.selection(), model.selection("FACE", "Extrusion_1_1/To_Face"), 0, model.selection(), 0)
41 Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_2_1")], [model.selection("SOLID", "Extrusion_3_1")])
42 Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOZ"))
43 SketchLine_1 = Sketch_3.addLine(-3.362323990279312, -0.5188129046480872, 0.8318943090987101, -0.5188129046480872)
44 SketchLine_2 = Sketch_3.addLine(0.8318943090987101, -0.5188129046480872, 0.8318943090987101, 7.155729512171993)
45 SketchLine_3 = Sketch_3.addLine(0.8318943090987101, 7.155729512171993, -3.362323990279312, 7.155729512171993)
46 SketchLine_4 = Sketch_3.addLine(-3.362323990279312, 7.155729512171993, -3.362323990279312, -0.5188129046480872)
47 SketchConstraintCoincidence_4 = Sketch_3.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
48 SketchConstraintCoincidence_5 = Sketch_3.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
49 SketchConstraintCoincidence_6 = Sketch_3.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
50 SketchConstraintCoincidence_7 = Sketch_3.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
51 SketchConstraintHorizontal_1 = Sketch_3.setHorizontal(SketchLine_1.result())
52 SketchConstraintVertical_1 = Sketch_3.setVertical(SketchLine_2.result())
53 SketchConstraintHorizontal_2 = Sketch_3.setHorizontal(SketchLine_3.result())
54 SketchConstraintVertical_2 = Sketch_3.setVertical(SketchLine_4.result())
55 model.do()
56 Face_1_objects = [model.selection("EDGE", "Sketch_2/SketchLine_2"), model.selection("EDGE", "Sketch_2/SketchLine_3"), model.selection("EDGE", "Sketch_2/SketchLine_4"), model.selection("EDGE", "Sketch_2/SketchLine_1")]
57 Face_1 = model.addFace(Part_1_doc, Face_1_objects)
58 Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_2_2f-SketchCircle_1_2r_wire")], model.selection(), model.selection("FACE", "Extrusion_2_1/From_Face"), 0, model.selection(), 0)
59 Cut_2 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_4_1")])
60 Partition_1_objects = [model.selection("SOLID", "Cut_1_1"), model.selection("SOLID", "Cut_2_1"), model.selection("FACE", "Face_1_1")]
61 Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects)
62 Remove_SubShapes_1_objects_1 = [model.selection("SOLID", "Partition_1_1_1_1"), model.selection("SOLID", "Partition_1_1_1_2"), model.selection("SOLID", "Partition_1_1_1_3"), model.selection("SOLID", "Partition_1_1_1_4")]
63 Remove_SubShapes_1 = model.addRemoveSubShapes(Part_1_doc, model.selection("COMPOUND", "Partition_1_1"))
64 Remove_SubShapes_1.setSubShapesToKeep(Remove_SubShapes_1_objects_1)
65 model.do()
66 model.end()
67
68 # check that remove sub-shapes contains correct selection
69 from ModelAPI import *
70 aFactory = ModelAPI_Session.get().validators()
71 assert(aFactory.validate(Remove_SubShapes_1.feature()))
72 assert(Remove_SubShapes_1.subshapesToKeep().size() == 4)
73 assert(Remove_SubShapes_1.subshapesToKeep().value(0).namingName() == "Partition_1_1_1_1")
74 assert(Remove_SubShapes_1.subshapesToKeep().value(1).namingName() == "Partition_1_1_1_2")
75 assert(Remove_SubShapes_1.subshapesToKeep().value(2).namingName() == "Partition_1_1_1_3")
76 assert(Remove_SubShapes_1.subshapesToKeep().value(3).namingName() == "Partition_1_1_1_4")
77 assert(Remove_SubShapes_1.subshapesToRemove().size() == 1)
78 assert(Remove_SubShapes_1.subshapesToRemove().value(0).namingName() == "Partition_1_1_2")