Salome HOME
Fix help errors
[modules/shaper.git] / doc / gui / tutorial.py
1 # -*- coding: utf-8 -*-
2
3 from SketchAPI import *
4
5 from salome.shaper import model
6
7 model.begin()
8 partSet = model.moduleDocument()
9 Part_1 = model.addPart(partSet)
10 Part_1_doc = Part_1.document()
11
12 # Parameters
13 model.addParameter(Part_1_doc, "h", "90", "nut height")
14 model.addParameter(Part_1_doc, "a", "115.4")
15
16 # Step1. Sketch.
17 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
18 SketchLine_1 = Sketch_1.addLine(-57.69999999999999, 99.93933159672423, 57.70000000000001, 99.93933159672423)
19 SketchLine_2 = Sketch_1.addLine(57.70000000000001, 99.93933159672423, 0, 0)
20 SketchLine_2.setAuxiliary(True)
21 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
22 SketchLine_3 = Sketch_1.addLine(0, 0, -57.69999999999999, 99.93933159672423)
23 SketchLine_3.setAuxiliary(True)
24 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
25 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint())
26 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
27 SketchPoint_1 = SketchProjection_1.createdFeature()
28 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchAPI_Point(SketchPoint_1).coordinates())
29 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
30 SketchLine_4 = SketchProjection_2.createdFeature()
31 SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_4.result(), SketchLine_1.result())
32 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_1.result())
33 SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_1.result())
34 SketchMultiRotation_1 = Sketch_1.addRotation([SketchLine_1.result()], SketchAPI_Line(SketchLine_4).startPoint(), 360, 6, True)
35 [SketchLine_5, SketchLine_6, SketchLine_7, SketchLine_8, SketchLine_9] = SketchMultiRotation_1.rotated()
36 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), "a")
37 model.do()
38
39 # Step2. Polyline.
40 Point_2 = model.addPoint(Part_1_doc, 50, 0, 0)
41 Point_2.result().setColor(0, 0, 255)
42 Point_3 = model.addPoint(Part_1_doc, 80, 0, 0)
43 Point_3.result().setColor(0, 0, 255)
44 Point_4 = model.addPoint(Part_1_doc, 112, 0, 13)
45 Point_4.result().setColor(0, 0, 255)
46 Point_5 = model.addPoint(Part_1_doc, 112, 0, 48)
47 Point_5.result().setColor(0, 0, 255)
48 Point_6 = model.addPoint(Part_1_doc, 80, 0, 63)
49 Point_6.result().setColor(0, 0, 255)
50 Point_7 = model.addPoint(Part_1_doc, "80", "0", "h")
51 Point_7.result().setColor(0, 0, 255)
52 Point_8 = model.addPoint(Part_1_doc, "50", "0", "h")
53 Point_8.result().setColor(0, 0, 255)
54 Polyline_1_objects = [model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2"),
55                       model.selection("VERTEX", "Point_3"), model.selection("VERTEX", "Point_4"),
56                       model.selection("VERTEX", "Point_5"), model.selection("VERTEX", "Point_6"),
57                       model.selection("VERTEX", "Point_7")]
58 Polyline_1 = model.addPolyline3D(Part_1_doc, Polyline_1_objects, True)
59
60 # Step3. Face.
61 Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Polyline_1_1")])
62
63 # Step4. Revolution.
64 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), 360, 0)
65
66 # Step5. Extrusion.
67 Wire = model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r")
68 To = model.selection("FACE", "Revolution_1_1/Generated_Face_6")
69 From = model.selection("FACE", "Revolution_1_1/Generated_Face_1")
70
71 Extrusion_1 = model.addExtrusion(Part_1_doc, [Wire], model.selection("EDGE", "PartSet/OZ"), To, 0, From, 0)
72
73 # Step6. Common.
74 Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Revolution_1_1"), model.selection("SOLID", "Extrusion_1_1")])
75
76 # Step7. Fillet.
77 Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "Revolution_1_1/Generated_Face_5&Common_1_1/Modified_Face_11")], 10)
78
79 # Step8. Box.
80 Box_1 = model.addBox(Part_1_doc, 20, 120, 20)
81
82 # Step9. Translation.
83 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], -10, 20, 70)
84
85 # Step10. Angular Copy.
86 AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("EDGE", "PartSet/OZ"), 6)
87
88 # Step11. Cut.
89 Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Fillet_1_1")], [model.selection("COMPOUND", "AngularCopy_1_1")])
90 Cut_1.result().setColor(255, 214, 0)
91
92 model.do()
93 model.end()