2 from SketchResult import *
5 #reload(sketch) # Pour tester plus facilement
6 #reload(extrusion) # Pour tester plus facilement
8 def makeBox(aLength, aWidth, aHeight):
9 # Getting the active document
10 session = ModelAPI_Session.get()
11 part = session.activeDocument()
14 base = sketch.addTo(part)
15 sketch.setXOYPlane(base)
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)
25 # Creating the constraints
26 # NOTE : the following lines are currently not working in BR_PYTHON_PLUGIN branch
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)
33 sketch.makeParallel(sketch.getGeometry(l1), sketch.getGeometry(l3))
34 sketch.makeParallel(sketch.getGeometry(l2), sketch.getGeometry(l4))
36 sketch.makePerpendicular(sketch.getGeometry(l1), sketch.getGeometry(l4))
39 # Finalisation of the operation
40 builder = SketchResult(base)
42 # Creating a feature Extrusion
43 box = extrusion.addNew(builder, 50, part)
45 #return base.lastResult()
46 return extrusion.getBody(box)