4 from SketchResult import *
5 #reload(sketch) # Pour tester plus facilement
6 #reload(extrusion) # Pour tester plus facilement
8 def makeBox(aLength, aWidth, aHeight):
10 # Getting the active document
12 session = ModelAPI_Session.get()
13 part = session.activeDocument()
18 session.startOperation()
19 base = sketch.addTo(part)
20 sketch.setXOYPlane(base)
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)
31 # Creating the constraints
33 # NOTE : the following lines are currently not working in BR_PYTHON_PLUGIN branch
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)
40 sketch.makeParallel(sketch.getGeometry(l1), sketch.getGeometry(l3))
41 sketch.makeParallel(sketch.getGeometry(l2), sketch.getGeometry(l4))
43 sketch.makePerpendicular(sketch.getGeometry(l1), sketch.getGeometry(l4))
46 # Finalisation of the operation
48 builder = SketchResult(base)
50 # Creating a feature Extrusion
51 box = extrusion.addNew(builder, 50, part)
52 session.finishOperation()
54 #return base.lastResult()
55 return extrusion.getBody(box)