Salome HOME
66a6d774db95bdfc6fafd302c2a2c8dbddc5e887
[modules/shaper.git] / src / FeaturesPlugin / Test / TestPlacement_ErrorMsg.py
1 # Copyright (C) 2018-2023  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 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
27 SketchCircle_1 = Sketch_1.addCircle(-16.57843122838298, -30.87163595652513, 16.88033171559421)
28 SketchCircle_2 = Sketch_1.addCircle(29.74848722752363, 33.32178840955915, 9.026354269133289)
29 model.do()
30 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
31 model.do()
32 model.end()
33
34 from ModelAPI import *
35 aSession = ModelAPI_Session.get()
36
37 aShapeToMove = Extrusion_1.feature().results()[1]
38
39 # Verify Placement errors on low-level
40 aSession.startOperation()
41 aPlacementFt = featureToCompositeFeature(Part_1.feature()).addFeature("Placement")
42 aPlacementFt.execute()
43 aSession.finishOperation()
44 assert(aPlacementFt.error() != "")
45
46 aSession.startOperation()
47 aPlacementFt.selectionList("placement_objects_list").append(aShapeToMove, aShapeToMove.shape())
48 aPlacementFt.execute()
49 aSession.finishOperation()
50 assert(aPlacementFt.error() != "")
51
52 aSession.startOperation()
53 aPlacementFt.selection("placement_start_shape").selectSubShape("FACE", "Extrusion_1_2/To_Face")
54 aPlacementFt.execute()
55 aSession.finishOperation()
56 assert(aPlacementFt.error() != "")
57
58 aSession.startOperation()
59 aPlacementFt.selection("placement_start_shape").selectSubShape("FACE", "Extrusion_1_2/Generated_Face&Sketch_1/SketchCircle_2_2")
60 aPlacementFt.selection("placement_end_shape").selectSubShape("FACE", "Extrusion_1_1/To_Face")
61 aPlacementFt.execute()
62 aSession.finishOperation()
63 assert(aPlacementFt.error() != "")
64
65 aSession.startOperation()
66 aPlacementFt.selection("placement_start_shape").selectSubShape("EDGE", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchCircle_2_2][Extrusion_1_2/To_Face]")
67 aPlacementFt.selection("placement_end_shape").selectSubShape("FACE", "Extrusion_1_1/To_Face")
68 aPlacementFt.execute()
69 aSession.finishOperation()
70 assert(aPlacementFt.error() != "")
71
72 # Create correct Placement
73 aSession.startOperation()
74 aPlacementFt.selection("placement_start_shape").selectSubShape("FACE", "Extrusion_1_2/To_Face")
75 aPlacementFt.selection("placement_end_shape").selectSubShape("FACE", "Extrusion_1_1/To_Face")
76 aPlacementFt.boolean("placement_reverse_direction").setValue(False)
77 aPlacementFt.boolean("placement_centering").setValue(True)
78 aPlacementFt.execute()
79 aSession.finishOperation()
80 assert(aPlacementFt.error() == "")
81
82
83 model.begin()
84 Placement_2 = model.addPlacement(Part_1_doc, [model.selection("SOLID", "Placement_1_1")], model.selection("COMPOUND", "Sketch_1"), model.selection("FACE", "Extrusion_1_1/To_Face"), False, False)
85 assert(Placement_2.feature().error() != "")
86 Part_1_doc.removeFeature(Placement_2.feature())
87 model.end()