1 ## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 ## This library is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU Lesser General Public
5 ## License as published by the Free Software Foundation; either
6 ## version 2.1 of the License, or (at your option) any later version.
8 ## This library is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ## Lesser General Public License for more details.
13 ## You should have received a copy of the GNU Lesser General Public
14 ## License along with this library; if not, write to the Free Software
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 # Creation of a box using the end-user API
22 # Author: Daniel Brunier-Coulin
23 # -----------------------------
25 from salome.shaper import model
31 mypartset = model.moduleDocument()
36 mypart = model.addPart(mypartset).document()
39 # Creating the base of the box
41 mybase = model.addSketch(mypart, model.defaultPlane("XOY"))
43 l1 = mybase.addLine(0, 0, 0, 25)
44 l2 = mybase.addLine(0, 25, 25, 25)
45 l3 = mybase.addLine(25, 25, 25, 0)
46 l4 = mybase.addLine(25, 0, 0, 0)
48 mybase.setCoincident(l1.endPoint(), l2.startPoint())
49 mybase.setCoincident(l2.endPoint(), l3.startPoint())
50 mybase.setCoincident(l3.endPoint(), l4.startPoint())
51 mybase.setCoincident(l4.endPoint(), l1.startPoint())
53 mybase.setParallel(l1, l3)
54 mybase.setParallel(l2, l4)
56 mybase.setPerpendicular(l1, l4)
58 mybase.setVertical(l1)
59 mybase.setFixed(l1.startPoint())
61 mywidth = mybase.setLength(l1, 50)
62 mylength = mybase.setDistance(l1.startPoint(), l3, 50)
65 # Creating the extrusion
67 mybox = model.addExtrusion(mypart, mybase.selectFace(), 50)
70 # Creating a cylinder on a face of the box
72 thisface = "Extrusion_1_1/Generated_Face_2"
73 thisxmax = "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1"
74 thiszmax = "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1_1"
76 mystand = model.addSketch(mypart, thisface)
78 c1 = mystand.addCircle(0, 25, 5)
79 l1 = mystand.addLine(thisxmax)
80 l2 = mystand.addLine(thiszmax)
82 mystand.setDistance(c1.center(), l1, 10)
83 mystand.setDistance(c1.center(), l2, 10)
87 myboss = model.addExtrusion(mypart, mystand.selectFace(), -5)
90 # Subtracting the cylinder to the box
92 model.addCut(mypart, mybox.results(), myboss.results())
99 mybase.setValue(mylength, 100)
104 assert(model.checkPythonDump())