+# Copyright (C) 2014-2023 CEA, EDF
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
# Creation of a box using the end-user API
# Author: Daniel Brunier-Coulin
# -----------------------------
-import model
+from salome.shaper import model
# Initialisation
mybase = model.addSketch(mypart, model.defaultPlane("XOY"))
-l1 = mybase.addLine(0, 0, 0, 1)
-l2 = mybase.addLine(0, 1, 1, 1)
-l3 = mybase.addLine(1, 1, 1, 0)
-l4 = mybase.addLine(1, 0, 0, 0)
+l1 = mybase.addLine(0, 0, 0, 25)
+l2 = mybase.addLine(0, 25, 25, 25)
+l3 = mybase.addLine(25, 25, 25, 0)
+l4 = mybase.addLine(25, 0, 0, 0)
mybase.setCoincident(l1.endPoint(), l2.startPoint())
mybase.setCoincident(l2.endPoint(), l3.startPoint())
mybase.setPerpendicular(l1, l4)
+mybase.setVertical(l1)
+mybase.setFixed(l1.startPoint())
+
mywidth = mybase.setLength(l1, 50)
mylength = mybase.setDistance(l1.startPoint(), l3, 50)
+model.do()
# Creating the extrusion
mybox = model.addExtrusion(mypart, mybase.selectFace(), 50)
+model.do()
# Creating a cylinder on a face of the box
-thisface = "Extrusion_1_1/Generated_Face_2"
-thisxmin = "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2"
-thisxmax = "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1"
-thiszmin = "Sketch_1/Edge5_1"
-thiszmax = "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1_1"
+thisface = "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2"
+thisxmax = "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1]"
+thiszmax = "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]"
mystand = model.addSketch(mypart, thisface)
c1 = mystand.addCircle(0, 25, 5)
-mystand.setDistance(c1.center(), mystand.addLine(thisxmin), 10)
-mystand.setDistance(c1.center(), mystand.addLine(thiszmax), 10)
+l1 = mystand.addLine(thisxmax)
+l2 = mystand.addLine(thiszmax)
+model.do()
+mystand.setDistance(c1.center(), l1, 10)
+mystand.setDistance(c1.center(), l2, 10)
+model.do()
-mystand.execute()
myboss = model.addExtrusion(mypart, mystand.selectFace(), -5)
+model.do()
# Subtracting the cylinder to the box
-model.addCut(mypart, mybox.result(), myboss.result())
+model.addCut(mypart, mybox.results(), myboss.results())
model.end()
model.begin()
mybase.setValue(mylength, 100)
+model.do()
mybox.setSize(80)
model.end()
+
+assert(model.checkPythonDump())