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"))
25 p2 = geom.Pnt2d(0, 25)
26 p3 = geom.Pnt2d(25, 25)
27 p4 = geom.Pnt2d(25, 0)
29 line = model.addPolygon(mybase, p1, p2, p3, p4)
31 mybase.setParallel(line[0], line[2])
32 mybase.setParallel(line[1], line[3])
33 mybase.setPerpendicular(line[0], line[3])
35 mybase.setVertical(line[0])
36 mybase.setFixed(line[0].startPoint())
38 mywidth = mybase.setLength(line[0], 50)
39 mylength = mybase.setDistance(line[0].startPoint(), line[2], 50)
42 # Creating the extrusion
44 mybox = model.addExtrusion(mypart, mybase.selectFace(), 50)
48 # Creating a cylinder on a face of the box
50 thisface = "Extrusion_1_1/Generated_Face_2"
51 thisxmin = "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2"
52 thiszmax = "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1_1"
54 mystand = model.addSketch(mypart, thisface)
55 circle = mystand.addCircle(0, 25, 5)
56 mystand.setDistance(circle.center(), mystand.addLine(thisxmin), 10)
57 mystand.setDistance(circle.center(), mystand.addLine(thiszmax), 10)
60 myboss = model.addExtrusion(mypart, mystand.selectFace(), -5)
63 # Subtracting the cylinder to the box
65 model.addCut(mypart, mybox.results(), myboss.results())
72 mybase.setValue(mylength, 100)
77 assert(model.checkPythonDump())