]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchPlugin/doc/examples/approximation.py
Salome HOME
bos #29482 Merge branch 'CR29482'
[modules/shaper.git] / src / SketchPlugin / doc / examples / approximation.py
1 from salome.shaper import model
2
3 model.begin()
4 partSet = model.moduleDocument()
5
6 ### Create Part
7 Part_1 = model.addPart(partSet)
8 Part_1_doc = Part_1.document()
9
10 ### Create Sketch
11 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
12
13 ### Create SketchPoints
14 SketchPoint_1 = Sketch_1.addPoint(-70.28350515463917, 1.388316151202744)
15 SketchPoint_2 = Sketch_1.addPoint(-26.89862542955327, 51.7147766323024)
16 SketchPoint_3 = Sketch_1.addPoint(40.08762886597938, 32.27835051546391)
17 SketchPoint_4 = Sketch_1.addPoint(66.46563573883162, -29.8487972508591)
18
19 ### Create approximating curve
20 ApproximationPoints = [SketchPoint_1.coordinates(),
21                        SketchPoint_2.coordinates(),
22                        SketchPoint_3.coordinates(),
23                        SketchPoint_4.coordinates()]
24 SketchBSpline_1 = Sketch_1.addApproximation(ApproximationPoints, precision = 30)
25 Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchBSpline_1.startPoint())
26 Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchBSpline_1.endPoint())
27
28 ### Create periodic approximating curve
29 SketchBSpline_2 = Sketch_1.addApproximation(ApproximationPoints, precision = 30, periodic = True)
30
31 ### Create closed approximating curve
32 SketchBSpline_3 = Sketch_1.addApproximation(ApproximationPoints, precision = 30, closed = True)
33 Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchBSpline_3.startPoint())
34 Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchBSpline_3.endPoint())
35
36 model.do()
37
38 model.end()