1 # Creation of Platine model using the end-user API
2 # Author: Sergey POKHODENKO
3 # -----------------------------
10 partset = model.moduleDocument()
13 part = model.addPart(partset).document()
20 model.addParameter(part, "L", L)
21 model.addParameter(part, "E", E)
22 model.addParameter(part, "P", P)
26 sketch = model.addSketch(part, model.defaultPlane("YOZ"))
28 points = [(0, 0), (0, L), (L, L), (L, 0)]
29 geom_points = [geom.Pnt2d(*p) for p in points]
30 left, top, right, bottom = sketch.addPolygon(*geom_points)
33 sketch.setRigid(left.startPoint())
35 sketch.setHorizontal(bottom.result())
36 sketch.setHorizontal(top.result())
38 sketch.setVertical(right.result())
39 sketch.setVertical(left.result())
41 sketch.setLength(top.result(), "L")
42 sketch.setLength(left.result(), "L")
44 sketch.setFillet(left.endPoint(), 32)
49 body = model.addExtrusion(part, sketch.selectFace(), "E")
57 sketch = model.addSketch(part, "Extrusion_1_1/LateralFace_2")
60 points = [(0, 0), (0, L), (P, L), (P, 16 + 16), (P - 20, 16 + 16), (P - 20, 16), (P, 16), (P, 0)]
61 points = [(p[0], -p[1]) for p in points] # as we look to back of the face
62 geom_points = [geom.Pnt2d(*p) for p in points]
63 left, top, v2, h2, v1, h1, right, bottom = sketch.addPolygon(*geom_points)
65 points = [(P - 20, 16 + 16 / 2), (P - 20, 16), (P - 20, 16 + 16)]
66 points = [(p[0], -p[1]) for p in points] # as we look to back of the face
67 center, start, end = [geom.Pnt2d(*p) for p in points]
68 arc = sketch.addArc(center, start, end, inversed=True)
74 sketch.setParallel(left.result(), right.result())
75 sketch.setParallel(left.result(), v2.result())
76 sketch.setParallel(bottom.result(), h1.result())
77 sketch.setParallel(top.result(), h2.result())
79 sketch.setPerpendicular(left.result(), bottom.result())
80 sketch.setPerpendicular(left.result(), top.result())
82 sketch.setEqual(top.result(), bottom.result())
83 sketch.setEqual(h1.result(), h2.result())
85 sketch.setLength(top.result(), "P")
86 sketch.setLength(right.result(), 16)
87 sketch.setLength(v1.result(), 16)
88 sketch.setLength(h2.result(), 20)
90 sketch.setCoincident(arc.center(), v1.result())
91 sketch.setCoincident(arc.startPoint(), h2.endPoint())
92 sketch.setCoincident(arc.endPoint(), h1.startPoint())
95 left_e = sketch.addLine("Extrusion_1_1/LateralFace_2|Extrusion_1_1/ToFace_1")
96 sketch.setCoincident(left_e.startPoint(), left.endPoint())
97 sketch.setCoincident(left_e.endPoint(), left.startPoint())
102 body = model.addExtrusion(part, sketch.selectFace(), "-E")
110 sketch = model.addSketch(part, "Boolean_1_1/Modified_3")
112 # Create base polygon
113 H, L, l, r = 28, 40, 8, 12
115 points = [(0, 0), (0, H), (l, H), (l + 2 * r, H), (L, H), (L, 0)]
116 points = [(p[0], -p[1]) for p in points] # as we look to back of the face
117 geom_points = [geom.Pnt2d(*p) for p in points]
118 left, top_left, top_middle, top_right, right, bottom, = sketch.addPolygon(*geom_points)
120 points = [(l + r, H), (l, H), (l + 2 * r, H)]
121 points = [(p[0], -p[1]) for p in points] # as we look to back of the face
122 center, start, end = [geom.Pnt2d(*p) for p in points]
123 arc = sketch.addArc(center, start, end)
126 top_middle.setAuxiliary(True)
129 sketch.setParallel(bottom.result(), top_left.result())
130 sketch.setParallel(bottom.result(), top_right.result())
132 sketch.setPerpendicular(bottom.result(), left.result())
133 sketch.setPerpendicular(bottom.result(), right.result())
135 sketch.setEqual(left.result(), right.result())
137 sketch.setLength(bottom.result(), L)
138 sketch.setLength(right.result(), H)
139 sketch.setLength(top_left.result(), l)
141 sketch.setCoincident(top_middle.result(), arc.center())
142 sketch.setCoincident(top_middle.endPoint(), arc.startPoint())
143 sketch.setCoincident(top_middle.startPoint(), arc.endPoint())
145 sketch.setRadius(arc.result(), r)
148 bottom_e = sketch.addLine("Boolean_1_1/Modified_1|Boolean_1_1/Modified_3")
149 sketch.setCoincident(bottom_e.result(), bottom.startPoint())
150 sketch.setCoincident(bottom_e.startPoint(), bottom.endPoint())
155 body = model.addExtrusion(part, sketch.selectFace(), "-(L-22)")
162 # Create XOZ 2nd sketch
163 sketch = model.addSketch(part, "Boolean_2_1/Modified_7")
165 # Create base polygon
166 points = [(0, 0), (0, 1), (1, 0)]
167 points = [(p[0], -p[1]) for p in points] # as we look to back of the face
168 geom_points = [geom.Pnt2d(*p) for p in points]
169 left, diagonal, bottom = sketch.addPolygon(*geom_points)
172 bottom_e = sketch.addLine("Boolean_2_1/Modified_8|Boolean_2_1/Modified_7")
173 sketch.setCoincident(bottom_e.endPoint(), bottom.startPoint())
174 sketch.setCoincident(bottom_e.startPoint(), left.startPoint())
176 left_e = sketch.addLine("Boolean_2_1/Modified_3|Boolean_2_1/Modified_2")
177 sketch.setCoincident(left_e.startPoint(), left.endPoint())
182 body = model.addExtrusion(part, sketch.selectFace(), "-12")
192 boolean = model.addAddition(part, b1.result() + b2.result())
197 boolean = model.addAddition(part, boolean.result() + b3.result())
202 boolean = model.addAddition(part, boolean.result() + b4.result())