1 # Copyright (C) 2014-2020 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from SketchAPI import *
22 from salome.shaper import model
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 WidthParam = model.addParameter(Part_1_doc, "Width", "64")
29 model.addParameter(Part_1_doc, "Depth", "33")
30 model.addParameter(Part_1_doc, "D1_out", "38")
31 model.addParameter(Part_1_doc, "D2_out", "33")
32 model.addParameter(Part_1_doc, "D3_out", "30")
33 model.addParameter(Part_1_doc, "D4_out", "20")
34 model.addParameter(Part_1_doc, "D1_in", "21")
35 model.addParameter(Part_1_doc, "D2_in", "5")
36 model.addParameter(Part_1_doc, "Channel_Depth", "1.3")
37 model.addParameter(Part_1_doc, "Channel_Width", "1.5")
38 model.addParameter(Part_1_doc, "Drill1_Loc", "7.5")
39 model.addParameter(Part_1_doc, "Drill1_Radius", "2.25")
40 model.addParameter(Part_1_doc, "Drill1Holder_Width", "8")
41 model.addParameter(Part_1_doc, "Drill2_Loc", "6.5")
42 model.addParameter(Part_1_doc, "Drill2_Radius", "1.4")
43 model.addParameter(Part_1_doc, "Drill2_InnerRadius", "0.5")
44 model.addParameter(Part_1_doc, "Drill2_DepthMin", "6.5")
45 model.addParameter(Part_1_doc, "Drill2_DepthMax", "7.5")
46 model.addParameter(Part_1_doc, "Chamfer", "0.5")
47 model.addParameter(Part_1_doc, "Fillet1", "5")
48 model.addParameter(Part_1_doc, "Fillet2", "0.3")
49 model.addParameter(Part_1_doc, "Fillet3", "0.5")
50 model.addParameter(Part_1_doc, "Slot_Width", "8")
51 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
52 SketchLine_1 = Sketch_1.addLine(0, 3, 0.5, 2.5)
53 SketchLine_2 = Sketch_1.addLine(0.5, 2.5, 9.5, 2.5)
54 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
55 SketchLine_3 = Sketch_1.addLine(9.5, 2.5, 9.5, 3.1)
56 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
57 SketchLine_4 = Sketch_1.addLine(9.5, 3.1, 24.86574363608673, 3.1)
58 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
59 SketchLine_5 = Sketch_1.addLine(24.86574363608673, 3.1, 26, 3.3)
60 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
61 SketchLine_6 = Sketch_1.addLine(26, 3.3, 26, 5.5)
62 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
63 SketchLine_7 = Sketch_1.addLine(31, 10.5, 64, 10.5)
64 SketchLine_8 = Sketch_1.addLine(64, 10.5, 64, 15)
65 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
66 SketchLine_9 = Sketch_1.addLine(64, 15, 61, 15)
67 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
68 SketchLine_10 = Sketch_1.addLine(61, 15, 61, 12.75)
69 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
70 SketchLine_11 = Sketch_1.addLine(61, 12.75, 58, 12.75)
71 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
72 SketchLine_12 = Sketch_1.addLine(58, 12.75, 58, 14)
73 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint())
74 SketchLine_13 = Sketch_1.addLine(58, 14, 57, 15)
75 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint())
76 SketchLine_14 = Sketch_1.addLine(57, 15, 54, 15)
77 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint())
78 SketchLine_15 = Sketch_1.addLine(54, 15, 52.5, 16.5)
79 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint())
80 SketchLine_16 = Sketch_1.addLine(52.5, 16.5, 35, 16.5)
81 SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint())
82 SketchLine_17 = Sketch_1.addLine(35, 16.5, 34, 15.5)
83 SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_16.endPoint(), SketchLine_17.startPoint())
84 SketchLine_18 = Sketch_1.addLine(34, 15.5, 32, 15.5)
85 SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_17.endPoint(), SketchLine_18.startPoint())
86 SketchLine_19 = Sketch_1.addLine(32, 15.5, 32, 19)
87 SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint())
88 SketchLine_20 = Sketch_1.addLine(32, 19, 22.5, 19)
89 SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchLine_19.endPoint(), SketchLine_20.startPoint())
90 SketchLine_21 = Sketch_1.addLine(22.5, 19, 22.5, 13)
91 SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchLine_20.endPoint(), SketchLine_21.startPoint())
92 SketchLine_22 = Sketch_1.addLine(22.5, 13, 22, 12.5)
93 SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchLine_21.endPoint(), SketchLine_22.startPoint())
94 SketchLine_23 = Sketch_1.addLine(22, 12.5, 22, 10)
95 SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint())
96 SketchLine_24 = Sketch_1.addLine(22, 10, 20, 10)
97 SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchLine_23.endPoint(), SketchLine_24.startPoint())
98 SketchLine_25 = Sketch_1.addLine(20, 10, 20, 8.699999999999999)
99 SketchConstraintCoincidence_23 = Sketch_1.setCoincident(SketchLine_24.endPoint(), SketchLine_25.startPoint())
100 SketchLine_26 = Sketch_1.addLine(20, 8.699999999999999, 18.5, 8.699999999999999)
101 SketchConstraintCoincidence_24 = Sketch_1.setCoincident(SketchLine_25.endPoint(), SketchLine_26.startPoint())
102 SketchLine_27 = Sketch_1.addLine(18.5, 8.699999999999999, 18.5, 10)
103 SketchConstraintCoincidence_25 = Sketch_1.setCoincident(SketchLine_26.endPoint(), SketchLine_27.startPoint())
104 SketchLine_28 = Sketch_1.addLine(18.5, 10, 10.5, 10)
105 SketchConstraintCoincidence_26 = Sketch_1.setCoincident(SketchLine_27.endPoint(), SketchLine_28.startPoint())
106 SketchLine_29 = Sketch_1.addLine(10.5, 10, 10.5, 8.699999999999999)
107 SketchConstraintCoincidence_27 = Sketch_1.setCoincident(SketchLine_28.endPoint(), SketchLine_29.startPoint())
108 SketchLine_30 = Sketch_1.addLine(10.5, 8.699999999999999, 9, 8.699999999999999)
109 SketchConstraintCoincidence_28 = Sketch_1.setCoincident(SketchLine_29.endPoint(), SketchLine_30.startPoint())
110 SketchLine_31 = Sketch_1.addLine(9, 8.699999999999999, 9, 10)
111 SketchConstraintCoincidence_29 = Sketch_1.setCoincident(SketchLine_30.endPoint(), SketchLine_31.startPoint())
112 SketchLine_32 = Sketch_1.addLine(9, 10, 0.5, 10)
113 SketchConstraintCoincidence_30 = Sketch_1.setCoincident(SketchLine_31.endPoint(), SketchLine_32.startPoint())
114 SketchLine_33 = Sketch_1.addLine(0.5, 10, 0, 9.5)
115 SketchConstraintCoincidence_31 = Sketch_1.setCoincident(SketchLine_32.endPoint(), SketchLine_33.startPoint())
116 SketchLine_34 = Sketch_1.addLine(0, 9.5, 0, 3)
117 SketchConstraintCoincidence_32 = Sketch_1.setCoincident(SketchLine_33.endPoint(), SketchLine_34.startPoint())
118 SketchConstraintCoincidence_33 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_34.endPoint())
119 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_2.result())
120 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result())
121 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_4.result())
122 SketchConstraintAngle_1 = Sketch_1.setAngleComplementary(SketchLine_4.result(), SketchLine_5.result(), 10.00000000008873)
123 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_6.result())
124 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_7.result())
125 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
126 SketchPoint_1 = SketchProjection_1.createdFeature()
127 SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_1.endPoint(), "D2_in/2")
128 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_8.result())
129 SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_9.result())
130 SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_16.result(), SketchLine_7.result())
131 SketchConstraintAngle_2 = Sketch_1.setAngleComplementary(SketchLine_15.result(), SketchLine_16.result(), 45.00000000000006)
132 SketchConstraintAngle_3 = Sketch_1.setAngleComplementary(SketchLine_13.result(), SketchLine_14.result(), 45.00000000000006)
133 SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_12.result())
134 SketchConstraintVertical_5 = Sketch_1.setVertical(SketchLine_10.result())
135 SketchConstraintHorizontal_5 = Sketch_1.setHorizontal(SketchLine_11.result())
136 SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_17.result(), SketchLine_15.result())
137 SketchConstraintVertical_6 = Sketch_1.setVertical(SketchLine_19.result())
138 SketchConstraintHorizontal_6 = Sketch_1.setHorizontal(SketchLine_18.result())
139 SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_20.result(), SketchLine_7.result())
140 SketchConstraintParallel_3 = Sketch_1.setParallel(SketchLine_21.result(), SketchLine_19.result())
141 SketchConstraintVertical_7 = Sketch_1.setVertical(SketchLine_23.result())
142 SketchConstraintHorizontal_7 = Sketch_1.setHorizontal(SketchLine_24.result())
143 SketchConstraintCollinear_1 = Sketch_1.setCollinear(SketchLine_28.result(), SketchLine_24.result())
144 SketchConstraintCollinear_2 = Sketch_1.setCollinear(SketchLine_32.result(), SketchLine_28.result())
145 SketchConstraintVertical_8 = Sketch_1.setVertical(SketchLine_34.result())
146 SketchConstraintHorizontal_8 = Sketch_1.setHorizontal(SketchLine_30.result())
147 SketchConstraintCollinear_3 = Sketch_1.setCollinear(SketchLine_26.result(), SketchLine_30.result())
148 SketchConstraintVertical_9 = Sketch_1.setVertical(SketchLine_31.result())
149 SketchConstraintVertical_10 = Sketch_1.setVertical(SketchLine_29.result())
150 SketchConstraintVertical_11 = Sketch_1.setVertical(SketchLine_27.result())
151 SketchConstraintVertical_12 = Sketch_1.setVertical(SketchLine_25.result())
152 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_24.result(), "D4_out/2", True)
153 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_30.result(), "D4_out/2-Channel_Depth", True)
154 SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_34.endPoint(), SketchLine_1.endPoint(), "Chamfer")
155 SketchConstraintDistanceVertical_2 = Sketch_1.setVerticalDistance(SketchLine_1.endPoint(), SketchLine_1.startPoint(), "Chamfer")
156 SketchConstraintDistanceHorizontal_2 = Sketch_1.setHorizontalDistance(SketchLine_34.startPoint(), SketchLine_33.startPoint(), "Chamfer")
157 SketchConstraintDistanceVertical_3 = Sketch_1.setVerticalDistance(SketchLine_34.startPoint(), SketchLine_33.startPoint(), "Chamfer")
158 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
159 SketchLine_35 = SketchProjection_2.createdFeature()
160 SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_3.endPoint(), SketchLine_35.result(), "D2_in/2+0.6", True)
161 SketchConstraintDistanceHorizontal_3 = Sketch_1.setHorizontalDistance(SketchLine_3.endPoint(), SketchLine_5.endPoint(), "Depth/2")
162 SketchConstraintDistance_4 = Sketch_1.setDistance(SketchLine_5.endPoint(), SketchLine_35.result(), "D2_in/2+0.8", True)
163 SketchArc_1 = Sketch_1.addArc(31, 5.5, 31, 10.5, 26, 5.5, False)
164 SketchConstraintCoincidence_34 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_7.startPoint())
165 SketchConstraintCoincidence_35 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_6.endPoint())
166 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_7.result())
167 SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_6.result())
168 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "Fillet1")
169 SketchConstraintDistance_5 = Sketch_1.setDistance(SketchLine_7.endPoint(), SketchLine_35.result(), "D1_in/2", True)
170 SketchConstraintAngle_4 = Sketch_1.setAngleComplementary(SketchLine_23.result(), SketchLine_22.result(), 44.99999999999991)
171 SketchConstraintCollinear_4 = Sketch_1.setCollinear(SketchLine_14.result(), SketchLine_9.result())
172 SketchConstraintDistanceHorizontal_4 = Sketch_1.setHorizontalDistance(SketchLine_34.startPoint(), SketchLine_23.startPoint(), "Width/32*11")
173 SketchConstraintDistanceHorizontal_5 = Sketch_1.setHorizontalDistance(SketchLine_23.startPoint(), SketchLine_22.startPoint(), "Chamfer")
174 SketchConstraintDistanceHorizontal_6 = Sketch_1.setHorizontalDistance(SketchLine_15.startPoint(), SketchLine_8.endPoint(), 10)
175 SketchConstraintDistance_6 = Sketch_1.setDistance(SketchLine_8.endPoint(), SketchLine_35.result(), "D3_out/2", True)
176 SketchConstraintDistance_7 = Sketch_1.setDistance(SketchLine_11.startPoint(), SketchLine_35.result(), "(D3_out+D1_in)/4", True)
177 SketchConstraintDistanceHorizontal_7 = Sketch_1.setHorizontalDistance(SketchLine_10.startPoint(), SketchLine_8.endPoint(), 3)
178 SketchConstraintDistanceHorizontal_8 = Sketch_1.setHorizontalDistance(SketchLine_12.endPoint(), SketchLine_10.startPoint(), 3)
179 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_30.result(), SketchLine_26.result())
180 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_26.result(), "Channel_Width")
181 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_28.result(), "Drill1Holder_Width")
182 SketchConstraintDistanceHorizontal_9 = Sketch_1.setHorizontalDistance(SketchArc_1.center(), SketchLine_7.endPoint(), "Depth")
183 SketchConstraintDistance_8 = Sketch_1.setDistance(SketchLine_16.startPoint(), SketchLine_35.result(), "D2_out/2", True)
184 SketchConstraintDistanceHorizontal_10 = Sketch_1.setHorizontalDistance(SketchLine_20.startPoint(), SketchLine_8.endPoint(), "Width/2")
185 SketchConstraintDistance_9 = Sketch_1.setDistance(SketchLine_17.endPoint(), SketchLine_35.result(), "D2_out/2-1", True)
186 SketchConstraintDistanceHorizontal_11 = Sketch_1.setHorizontalDistance(SketchLine_20.startPoint(), SketchLine_17.endPoint(), 2)
187 SketchConstraintCoincidence_36 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_35).startPoint(), SketchLine_34.result())
188 SketchConstraintDistance_10 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_35).startPoint(), SketchLine_20.result(), "D1_out/2", True)
189 SketchPoint_2 = Sketch_1.addPoint(14.5, 10)
190 SketchConstraintCoincidence_37 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_28.result())
191 SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchPoint_2.coordinates(), SketchLine_28.result())
192 SketchConstraintDistanceHorizontal_12 = Sketch_1.setHorizontalDistance(SketchPoint_2.coordinates(), SketchLine_24.startPoint(), "Drill1_Loc")
193 SketchConstraintDistanceHorizontal_13 = Sketch_1.setHorizontalDistance(SketchLine_34.startPoint(), SketchLine_9.startPoint(), "Width")
194 SketchConstraintDistanceHorizontal_14 = Sketch_1.setHorizontalDistance(SketchLine_14.startPoint(), SketchLine_12.endPoint(), 1)
195 SketchConstraintDistance_11 = Sketch_1.setDistance(SketchLine_23.startPoint(), SketchLine_35.result(), "(D4_out+D2_in)/2", True)
197 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection("EDGE", "PartSet/OX"), 360, 0)
198 Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "PartSet/OY"), model.selection("VERTEX", "Sketch_1/SketchPoint_2"), True)
199 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
200 SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchPoint_2"), False)
201 SketchPoint_3 = SketchProjection_3.createdFeature()
202 SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8])"), False)
203 SketchLine_36 = SketchProjection_4.createdFeature()
204 SketchCircle_1 = Sketch_2.addCircle(14.5, 0, 2.25)
205 SketchConstraintCoincidence_38 = Sketch_2.setCoincident(SketchPoint_3.result(), SketchCircle_1.center())
206 SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_1.results()[1], "Drill1_Radius")
208 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")], model.selection(), model.selection("FACE", "PartSet/XOZ"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")])
209 Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_20]")], "Fillet1")
210 Fillet_2_objects = [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_31"), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_29"), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_27"), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25")]
211 Fillet_2 = model.addFillet(Part_1_doc, Fillet_2_objects, "Fillet2")
214 # update a parameter Width value to 80 and check that result is correct
215 WidthParam.setValue(80)
219 assert(ModelAPI.ModelAPI_Session.get().validators().validate(Fillet_2.feature()))
221 from GeomAPI import *
222 model.testHaveNamingByType(Fillet_2, model, Part_1_doc, GeomAPI_Shape.FACE)
226 assert(model.checkPythonDump())