Salome HOME
23d383f35825a9ba6da031fcda89f81001764153
[modules/shaper.git] / src / ConstructionPlugin / Test / TestAxis_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
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 # Axis by cylindrical face
68 aSession.startOperation()
69 Axis_1 = aPart.addFeature("Axis")
70 Axis_1.string("CreationMethod").setValue("AxisByCylindricalFaceCase")
71 Axis_1.selection("CylindricalFace").selectSubShape("COMPOUND", "Compound_2_1")
72 Axis_1.execute()
73 aSession.finishOperation()
74 assert(Axis_1.error() != "")
75
76 # Axis by dimensions
77 aSession.startOperation()
78 Axis_1.string("CreationMethod").setValue("AxisByDimensionsCase")
79 Axis_1.real("DX").setValue(0)
80 Axis_1.real("DY").setValue(0)
81 Axis_1.real("DZ").setValue(0)
82 Axis_1.execute()
83 assert(Axis_1.error() != "")
84 aSession.finishOperation()
85
86 # Axis by line
87 aSession.startOperation()
88 Axis_1.string("CreationMethod").setValue("by_line")
89 Axis_1.selection("line").selectSubShape("COMPOUND", "Compound_1_1")
90 Axis_1.execute()
91 assert(Axis_1.error() != "")
92 aSession.finishOperation()
93
94 # Axis by plane and point
95 aSession.startOperation()
96 Axis_1.string("CreationMethod").setValue("by_plane_and_point")
97 Axis_1.selection("point").selectSubShape("COMPOUND", "Compound_1_1")
98 Axis_1.selection("plane").selectSubShape("COMPOUND", "Compound_2_1")
99 Axis_1.execute()
100 assert(Axis_1.error() != "")
101 aSession.finishOperation()
102
103 # Axis by two planes
104 aSession.startOperation()
105 Axis_1.string("CreationMethod").setValue("by_two_planes")
106 Axis_1.selection("plane1").selectSubShape("COMPOUND", "Compound_2_1")
107 Axis_1.selection("plane2").selectSubShape("COMPOUND", "Compound_2_1")
108 Axis_1.execute()
109 assert(Axis_1.error() != "")
110 aSession.finishOperation()
111
112 aSession.startOperation()
113 Axis_1.selection("plane1").selectSubShape("COMPOUND", "Compound_1_1")
114 Axis_1.string("use_offset1").setValue("true")
115 Axis_1.real("offset1").setValue(10)
116 Axis_1.boolean("reverse_offset1").setValue(True)
117 Axis_1.execute()
118 assert(Axis_1.error() != "")
119 aSession.finishOperation()