]> SALOME platform Git repositories - modules/shaper.git/blob - src/ConstructionPlugin/Test/TestPlane_ErrorMsg.py
Salome HOME
Switch to SSL mode for tests : Get rid off all SALOME_TEST_DRIVER reference
[modules/shaper.git] / src / ConstructionPlugin / Test / TestPlane_ErrorMsg.py
1 # Copyright (C) 2018-2021  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
21 from ModelAPI import *
22 aSession = ModelAPI_Session.get()
23 aDocument = aSession.moduleDocument()
24
25 # Create a part
26 aSession.startOperation()
27 aPartFeature = aDocument.addFeature("Part")
28 aSession.finishOperation()
29 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
30 aPart = aPartResult.partDoc()
31
32 # Create auxiliary box
33 aSession.startOperation()
34 aBox = aPart.addFeature("Box")
35 aBox.string("CreationMethod").setValue("BoxByDimensions")
36 aBox.real("dx").setValue(50)
37 aBox.real("dy").setValue(50)
38 aBox.real("dz").setValue(50)
39 aSession.finishOperation()
40
41 # Create auxiliary compound
42 aSession.startOperation()
43 aCompound = aPart.addFeature("Compound")
44 aCompoundList = aCompound.selectionList("base_objects")
45 aCompoundList.append("Box_1_1/Front", "FACE")
46 aCompoundList.append("[Box_1_1/Left][Box_1_1/Top]", "EDGE")
47 aSession.finishOperation()
48
49 # Create auxiliary box 2
50 aSession.startOperation()
51 aBox = aPart.addFeature("Box")
52 aBox.string("CreationMethod").setValue("BoxByDimensions")
53 aBox.real("dx").setValue(50)
54 aBox.real("dy").setValue(50)
55 aBox.real("dz").setValue(50)
56 aSession.finishOperation()
57
58 # Create auxiliary compound 2
59 aSession.startOperation()
60 aCompound = aPart.addFeature("Compound")
61 aCompoundList = aCompound.selectionList("base_objects")
62 aCompoundList.append("[Box_2_1/Left][Box_2_1/Top]", "EDGE")
63 aCompoundList.append("Box_2_1/Front", "FACE")
64 aSession.finishOperation()
65
66
67 # Plane by line and point
68 aSession.startOperation()
69 Plane_1 = aPart.addFeature("Plane")
70 Plane_1.string("creation_method").setValue("by_line_and_point")
71 Plane_1.selection("line").selectSubShape("COMPOUND", "Compound_1_1")
72 Plane_1.selection("point").selectSubShape("VERTEX", "PartSet/Origin")
73 Plane_1.execute()
74 assert(Plane_1.error() != "")
75 aSession.finishOperation()
76
77 # Unsupported type
78 aSession.startOperation()
79 Plane_1.string("creation_method").setValue("by_rotation")
80 Plane_1.selection("plane").selectSubShape("COMPOUND", "Compound_1_1")
81 Plane_1.selection("axis").selectSubShape("COMPOUND", "Compound_1_1")
82 Plane_1.execute()
83 assert(Plane_1.error() != "")
84 aSession.finishOperation()
85
86 # By two parallel planes
87 aSession.startOperation()
88 Plane_1.string("creation_method").setValue("by_two_parallel_planes")
89 Plane_1.selection("plane1").selectSubShape("COMPOUND", "Compound_2_1")
90 Plane_1.selection("plane2").selectSubShape("COMPOUND", "Compound_2_1")
91 Plane_1.execute()
92 assert(Plane_1.error() != "")
93 aSession.finishOperation()
94
95 aSession.startOperation()
96 Plane_1.selection("plane1").selectSubShape("COMPOUND", "Compound_1_1")
97 Plane_1.execute()
98 assert(Plane_1.error() != "")
99 aSession.finishOperation()
100
101 # By distance from other plane
102 aSession.startOperation()
103 Plane_1.string("creation_method").setValue("by_other_plane")
104 Plane_1.string("by_other_plane_option").setValue("by_distance_from_other")
105 Plane_1.selection("plane").selectSubShape("COMPOUND", "Compound_2_1")
106 Plane_1.real("distance").setValue(10)
107 Plane_1.execute()
108 assert(Plane_1.error() != "")
109 aSession.finishOperation()
110
111 # By coincident point
112 aSession.startOperation()
113 Plane_1.string("by_other_plane_option").setValue("by_coincident_to_point")
114 Plane_1.selection("coincident_point").selectSubShape("COMPOUND", "Compound_1_1")
115 Plane_1.execute()
116 assert(Plane_1.error() != "")
117 aSession.finishOperation()
118
119 # By rotation
120 aSession.startOperation()
121 Plane_1.string("by_other_plane_option").setValue("by_rotation")
122 Plane_1.selection("axis").selectSubShape("COMPOUND", "Compound_1_1")
123 Plane_1.real("angle").setValue(90)
124 Plane_1.execute()
125 assert(Plane_1.error() != "")
126 aSession.finishOperation()
127
128 aSession.startOperation()
129 Plane_1.selection("plane").selectSubShape("COMPOUND", "Compound_1_1")
130 Plane_1.execute()
131 assert(Plane_1.error() != "")
132 aSession.finishOperation()