1 # Creation of a box using the end-user API
2 # Author: Daniel Brunier-Coulin
3 # -----------------------------
12 mypartset = model.moduleDocument()
17 mypart = model.addPart(mypartset).document()
20 # Creating the base of the box
22 mybase = model.addSketch(mypart, model.defaultPlane("XOY"))
29 line = mybase.addPolygon(p1, p2, p3, p4)
31 mybase.setParallel(line[0].result(), line[2].result())
32 mybase.setParallel(line[1].result(), line[3].result())
33 mybase.setPerpendicular(line[0].result(), line[3].result())
35 mywidth = mybase.setLength(line[0].result(), 50)
36 mylength = mybase.setDistance(line[0].startPoint(), line[2].result(), 50)
39 # Creating the extrusion
41 mybox = model.addExtrusion(mypart, mybase.selectFace(), 50)
44 # Creating a cylinder on a face of the box
46 thisface = "Extrusion_1_1/LateralFace_2"
47 thisxmin = "Extrusion_1_1/LateralFace_3|Extrusion_1_1/LateralFace_2"
48 thiszmax = "Extrusion_1_1/LateralFace_2|Extrusion_1_1/ToFace_1"
50 mystand = model.addSketch(mypart, thisface)
51 circle = mystand.addCircle(0, 25, 5)
52 mystand.setDistance(circle.center(), thisxmin, 10)
53 mystand.setDistance(circle.center(), thiszmax, 10)
55 myboss = model.addExtrusion(mypart, mystand.selectFace(), -5)
58 # Subtracting the cylinder to the box
60 model.addSubtraction(mypart, mybox.result(), myboss.result())
67 mybase.setValue(mylength, 100)