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, 1)
24 l2 = mybase.addLine(0, 1, 1, 1)
25 l3 = mybase.addLine(1, 1, 1, 0)
26 l4 = mybase.addLine(1, 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.result(), l3.result())
34 mybase.setParallel(l2.result(), l4.result())
36 mybase.setPerpendicular(l1.result(), l4.result())
38 mywidth = mybase.setLength(l1.result(), 50)
39 mylength = mybase.setDistance(l1.startPoint(), l3.result(), 50)
41 # Creating the extrusion
43 mybox = model.addExtrusion(mypart, mybase.selectFace(), 50)
45 # Creating a cylinder on a face of the box
47 thisface = "Extrusion_1_1/LateralFace_2"
48 thisxmin = "Extrusion_1_1/LateralFace_3&Extrusion_1_1/LateralFace_2"
49 thisxmax = "Extrusion_1_1/LateralFace_2&Extrusion_1_1/LateralFace_1"
50 thiszmin = "Sketch_1/Edge5_1"
51 thiszmax = "Extrusion_1_1/LateralFace_2&Extrusion_1_1/ToFace_1"
53 mystand = model.addSketch(mypart, thisface)
55 c1 = mystand.addCircle(0, 25, 5)
56 mystand.setDistance(c1.center(), thisxmin, 10)
57 mystand.setDistance(c1.center(), thiszmax, 10)
59 myboss = model.addExtrusion(mypart, mystand.selectFace(c1.result()), -5)
61 # Subtracting the cylinder to the box
63 model.addSubtraction(mypart, mybox.result(), myboss.result())
70 mybase.setValue(mylength, 100)