]> SALOME platform Git repositories - modules/shaper.git/blob - doc/gui/examples/tutorial.py
Salome HOME
d6519c9ea0a99ce390dfd58c01f63a1dccda885c
[modules/shaper.git] / doc / gui / examples / 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 # Step1. Sketch.
13 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
14 SketchLine_1 = Sketch_1.addLine(-57.7, 99.93933159672423, 57.7, 99.93933159672423)
15 SketchLine_2 = Sketch_1.addLine(57.7, 99.93933159672423, 0, 0)
16 SketchLine_2.setAuxiliary(True)
17 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
18 SketchLine_3 = Sketch_1.addLine(0, 0, -57.7, 99.93933159672423)
19 SketchLine_3.setAuxiliary(True)
20 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
21 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint())
22 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
23 SketchPoint_1 = SketchProjection_1.createdFeature()
24 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchAPI_Point(SketchPoint_1).coordinates())
25 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
26 SketchLine_4 = SketchProjection_2.createdFeature()
27 SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_4.result(), SketchLine_1.result())
28 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_1.result())
29 SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_1.result())
30 SketchMultiRotation_1 = Sketch_1.addRotation([SketchLine_1.result()], SketchAPI_Line(SketchLine_4).startPoint(), 360, 6, True)
31 [SketchLine_5, SketchLine_6, SketchLine_7, SketchLine_8, SketchLine_9] = SketchMultiRotation_1.rotated()
32 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 115.4)
33 model.do()
34
35 # Step2. Polyline.
36 Point_2 = model.addPoint(Part_1_doc, 50, 0, 0)
37 Point_2.result().setColor(0, 0, 255)
38 Point_3 = model.addPoint(Part_1_doc, 80, 0, 0)
39 Point_3.result().setColor(0, 0, 255)
40 Point_4 = model.addPoint(Part_1_doc, 112, 0, 13)
41 Point_4.result().setColor(0, 0, 255)
42 Point_5 = model.addPoint(Part_1_doc, 112, 0, 48)
43 Point_5.result().setColor(0, 0, 255)
44 Point_6 = model.addPoint(Part_1_doc, 80, 0, 63)
45 Point_6.result().setColor(0, 0, 255)
46 Point_7 = model.addPoint(Part_1_doc, 80, 0, 90)
47 Point_7.result().setColor(0, 0, 255)
48 Point_8 = model.addPoint(Part_1_doc, 50, 0, 90)
49 Point_8.result().setColor(0, 0, 255)
50
51 Polyline_1_objects = [model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2"),
52                       model.selection("VERTEX", "Point_3"), model.selection("VERTEX", "Point_4"),
53                       model.selection("VERTEX", "Point_5"), model.selection("VERTEX", "Point_6"),
54                       model.selection("VERTEX", "Point_7")]
55 Polyline_1 = model.addPolyline3D(Part_1_doc, Polyline_1_objects, True)
56
57 # Step3. Face.
58 Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Polyline_1_1")])
59
60 # Step4. Revolution.
61 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), 360, 0)
62
63 # Step5. Extrusion.
64 Wire_Name = "Sketch_1/Wire-SketchLine_1r-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r"
65 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", Wire_Name)], model.selection("EDGE", "PartSet/OZ"), 100, 0)
66
67 # Step6. Common.
68 Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Revolution_1_1"), model.selection("SOLID", "Extrusion_1_1")])
69
70 # Step7. Fillet.
71 Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "Revolution_1_1/Generated_Face_5&Common_1_1/Modified_Face_10")], 10)
72
73 # Step8. Box.
74 Box_1 = model.addBox(Part_1_doc, 20, 120, 20)
75
76 # Step9. Translation.
77 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], -10, 20, 70)
78
79 # Step10. Angular Copy.
80 AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("EDGE", "PartSet/OZ"), 6)
81
82 # Step11. Cut.
83 Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Fillet_1_1")], [model.selection("COMPOUND", "AngularCopy_1_1")])
84 Cut_1.result().setColor(255, 214, 0)
85
86 model.do()
87 model.end()