]> SALOME platform Git repositories - modules/shaper.git/blob - src/PythonFeaturesPlugin/examples.py
Salome HOME
75c5e7733ceff43b6dbb45f11e9975d15d202bd4
[modules/shaper.git] / src / PythonFeaturesPlugin / examples.py
1 from ModelAPI import *
2 import sketch
3 import extrusion
4 from SketchResult import *
5 #reload(sketch) # Pour tester plus facilement
6 #reload(extrusion) # Pour tester plus facilement
7
8 def makeBox(aLength, aWidth, aHeight):
9   print "makeBox"
10   # Getting the active document
11
12   session = ModelAPI_Session.get()
13   part = session.activeDocument()
14
15
16   # Starting the Sketch
17
18   session.startOperation()
19   base = sketch.addTo(part)
20   sketch.setXOYPlane(base)
21
22
23   # Creating the lines
24
25   l1  = sketch.addLine(10, 10, 10, 50, base)
26   l2  = sketch.addLine(10, 50, 60, 60, base)
27   l3  = sketch.addLine(60, 60, 50, 10, base)
28   l4  = sketch.addLine(50, 10, 10, 10, base)
29
30
31   # Creating the constraints
32   
33   # NOTE : the following lines are currently not working in BR_PYTHON_PLUGIN branch
34   """
35   sketch.makeCoincident(sketch.getEndPoint(l1), sketch.getStartPoint(l2), base)
36   sketch.makeCoincident(sketch.getEndPoint(l2), sketch.getStartPoint(l3), base)
37   sketch.makeCoincident(sketch.getEndPoint(l3), sketch.getStartPoint(l4), base)
38   sketch.makeCoincident(sketch.getEndPoint(l4), sketch.getStartPoint(l1), base)
39
40   sketch.makeParallel(sketch.getGeometry(l1), sketch.getGeometry(l3))
41   sketch.makeParallel(sketch.getGeometry(l2), sketch.getGeometry(l4))
42
43   sketch.makePerpendicular(sketch.getGeometry(l1), sketch.getGeometry(l4))
44   """
45
46   # Finalisation of the operation
47   
48   builder = SketchResult(base)
49
50   # Creating a feature Extrusion
51   box = extrusion.addNew(builder, 50, part)
52   session.finishOperation()
53
54   #return base.lastResult()
55   return extrusion.getBody(box)
56