X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPythonAPI%2Fexamples%2FPlatine.py;h=800ce0e05fbec009dcfc5543ffc70186ca71dc30;hb=d0f078983d5f74d45a6f28b3a4dfe8feadb2cdf7;hp=f0c236b51e0987dfc0132595c06dd216bd8f1117;hpb=cb3b1befb8fa7b3067d9263f94391108429d691a;p=modules%2Fshaper.git diff --git a/src/PythonAPI/examples/Platine.py b/src/PythonAPI/examples/Platine.py index f0c236b51..800ce0e05 100644 --- a/src/PythonAPI/examples/Platine.py +++ b/src/PythonAPI/examples/Platine.py @@ -1,9 +1,29 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## 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 Platine model using the end-user API # Author: Sergey POKHODENKO # ----------------------------- -import geom -import model +from salome.shaper import geom +from salome.shaper import model # START DEBUG PURPOSES # Should be removed @@ -47,20 +67,18 @@ def vertical_body(): sketch.setLength(top, "L") sketch.setLength(left, "L") - sketch.setFillet([left.endPoint()], 32) + sketch.setFilletWithRadius(left.endPoint(), 32) model.do() #!!! # Create extrusion body = model.addExtrusion(part, sketch.selectFace(), "E") - model.do() - return body def bottom_body(): # Create XOY sketch - sketch = model.addSketch(part, "Extrusion_1_1/Generated_Face_3") + sketch = model.addSketch(part, "Extrusion_1_1/Generated_Face_5") # Create base polygon points = [(0, 0), (0, L), (P, L), (P, 16 + 16), (P - 20, 16 + 16), (P - 20, 16), (P, 16), (P, 0)] @@ -68,7 +86,7 @@ def bottom_body(): geom_points = [geom.Pnt2d(*p) for p in points] left, top, v2, h2, v1, h1, right, bottom = model.addPolygon(sketch, *geom_points) - points = [(P - 20, 16 + 16 / 2), (P - 20, 16), (P - 20, 16 + 16)] + points = [(P - 20, 16 + 16 / 2), (P - 20, 16 + 16), (P - 20, 16)] points = [(p[0], -p[1]) for p in points] # as we look to back of the face center, start, end = [geom.Pnt2d(*p) for p in points] arc = sketch.addArc(center, start, end, True) @@ -93,14 +111,13 @@ def bottom_body(): sketch.setCoincident(arc.endPoint(), h1.startPoint()) # Binding - left_e = sketch.addLine("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1_1") + left_e = sketch.addLine("Extrusion_1_1/Generated_Face_5&Extrusion_1_1/To_Face_1_1") sketch.setCoincident(left_e.startPoint(), left.endPoint()) sketch.setCoincident(left_e.endPoint(), left.startPoint()) - model.do() #!!! - # Dimensions - sketch.setLength(v1, 16) + #sketch.setLength(v1, 16) + sketch.setLength(v2, 32) sketch.setLength(h2, 20) sketch.setLength(right, 16) sketch.setLength(top, "P") @@ -115,7 +132,7 @@ def bottom_body(): def body_3(): # Create XOZ sketch - sketch = model.addSketch(part, "Boolean_1_1/Modified_4") + sketch = model.addSketch(part, "Boolean_1_1/Modified_3") # Create base polygon H, L, l, r = 28, 40, 8, 12 @@ -153,7 +170,7 @@ def body_3(): sketch.setRadius(arc, r) # Binding - bottom_e = sketch.addLine("Boolean_1_1/Modified_5&Boolean_1_1/Modified_8") + bottom_e = sketch.addLine("Boolean_1_1/Modified_8&Boolean_1_1/Modified_5") sketch.setCoincident(bottom_e, bottom.startPoint()) sketch.setCoincident(bottom_e.startPoint(), bottom.endPoint()) @@ -162,8 +179,6 @@ def body_3(): # Create extrusion body = model.addExtrusion(part, sketch.selectFace(), "-(L-22)") - model.do() #!!! - return body def body_4(): @@ -181,7 +196,7 @@ def body_4(): sketch.setCoincident(bottom_e.endPoint(), bottom.startPoint()) sketch.setCoincident(bottom_e.startPoint(), left.startPoint()) - left_e = sketch.addLine("Boolean_2_1/Modified_6&Boolean_2_1/Modified_8") + left_e = sketch.addLine("Boolean_2_1/Modified_6&Boolean_2_1/Modified_7") sketch.setCoincident(left_e.startPoint(), left.endPoint()) model.do() #!!! @@ -189,20 +204,20 @@ def body_4(): # Create extrusion body = model.addExtrusion(part, sketch.selectFace(), "-12") - model.do() #!!! - return body b1 = vertical_body() b2 = bottom_body() -boolean = model.addFuse(part, b1.result() + b2.result()) +boolean = model.addFuse(part, b1.results() + b2.results()) +boolean.result().setName("Boolean_1_1") model.do() b3 = body_3() -boolean = model.addFuse(part, boolean.result() + b3.result()) +boolean = model.addFuse(part, boolean.results() + b3.results()) +boolean.result().setName("Boolean_2_1") model.do() # START DEBUG PURPOSES @@ -216,7 +231,7 @@ model.do() # END DEBUG PURPOSES b4 = body_4() -boolean = model.addFuse(part, boolean.result() + b4.result()) +boolean = model.addFuse(part, boolean.results() + b4.results()) model.end() assert(model.checkPythonDump())