1 # Creation of a box using the end-user API
2 # Author: Daniel Brunier-Coulin
3 # -----------------------------
11 mypartset = model.moduleDocument()
16 mypart = model.addPart(mypartset).document()
19 # Creating the base of the box
21 mybase = model.addSketch(mypart, model.defaultPlane("XOY"))
23 l1 = mybase.addLine(0, 0, 0, 25)
24 l2 = mybase.addLine(0, 25, 25, 25)
25 l3 = mybase.addLine(25, 25, 25, 0)
26 l4 = mybase.addLine(25, 0, 0, 0)
28 mybase.setCoincident(l1.endPoint(), l2.startPoint())
29 mybase.setCoincident(l2.endPoint(), l3.startPoint())
30 mybase.setCoincident(l3.endPoint(), l4.startPoint())
31 mybase.setCoincident(l4.endPoint(), l1.startPoint())
33 mybase.setParallel(l1, l3)
34 mybase.setParallel(l2, l4)
36 mybase.setPerpendicular(l1, l4)
38 mybase.setVertical(l1)
39 mybase.setFixed(l1.startPoint())
41 mywidth = mybase.setLength(l1, 50)
42 mylength = mybase.setDistance(l1.startPoint(), l3, 50)
45 # Creating the extrusion
47 mybox = model.addExtrusion(mypart, mybase.selectFace(), 50)
50 # Creating a cylinder on a face of the box
52 thisface = "Extrusion_1_1/Generated_Face_2"
53 thisxmax = "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2"
54 thiszmax = "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1_1"
56 mystand = model.addSketch(mypart, thisface)
58 c1 = mystand.addCircle(0, 25, 5)
59 l1 = mystand.addLine(thisxmax)
60 l2 = mystand.addLine(thiszmax)
62 mystand.setDistance(c1.center(), l1, 10)
63 mystand.setDistance(c1.center(), l2, 10)
67 myboss = model.addExtrusion(mypart, mystand.selectFace(), -5)
70 # Subtracting the cylinder to the box
72 model.addCut(mypart, mybox.results(), myboss.results())
79 mybase.setValue(mylength, 100)
84 assert(model.checkPythonDump())