1 # Creation of a box using the end-user API
2 # Author: Daniel Brunier-Coulin
3 # -----------------------------
11 mypartset = modeler.moduleDocument()
16 mypart = modeler.addPart(mypartset).document()
19 # Creating the base of the box
21 mybase = modeler.addSketch( mypart, modeler.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.endPointData(), l2.startPointData() )
29 mybase.setCoincident( l2.endPointData(), l3.startPointData() )
30 mybase.setCoincident( l3.endPointData(), l4.startPointData() )
31 mybase.setCoincident( l4.endPointData(), l1.startPointData() )
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.startPointData(), l3.result(), 50 )
42 # Creating the extrusion
44 mybox = modeler.addExtrusion( mypart, mybase.selectFace(), 50 )
47 # Creating a cylinder on a face of the box
49 thisface = "Extrusion_1/LateralFace_2"
50 thisxmin = "Extrusion_1/LateralFace_3|Extrusion_1/LateralFace_2"
51 thisxmax = "Extrusion_1/LateralFace_2|Extrusion_1/LateralFace_1"
52 thiszmin = "Sketch_1/Edge5_1"
53 thiszmax = "Extrusion_1/LateralFace_2|Extrusion_1/TopFace_1"
55 mystand = modeler.addSketch( mypart, thisface )
56 c1 = mystand.addCircle( 0, 25, 5)
57 mystand.setDistance( c1.centerData(), thisxmin, 10 )
58 mystand.setDistance( c1.centerData(), thiszmax, 10 )
60 myboss = modeler.addExtrusion( mypart, mystand.selectFace(c1.result()), -5 )
63 # Subtracting the cylinder to the box
65 modeler.addSubtraction( mypart, mybox.result(), myboss.result() )
72 mybase.setValue( mylength, 100 )