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