Salome HOME
PAL13375: batch with scripts based upon smesh.py and geompy.py. Init salome in geompy.py.
[modules/geom.git] / src / GEOM_SWIG / GEOM_Nut.py
1 #  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 #
4 #  This library is free software; you can redistribute it and/or
5 #  modify it under the terms of the GNU Lesser General Public
6 #  License as published by the Free Software Foundation; either
7 #  version 2.1 of the License.
8 #
9 #  This library is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 #  Lesser General Public License for more details.
13 #
14 #  You should have received a copy of the GNU Lesser General Public
15 #  License along with this library; if not, write to the Free Software
16 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 #####################################################################\r
21 #Created                :17/02/2005\r
22 #Auhtor                 :MASLOV Eugeny, KOVALTCHUK Alexey \r
23 #####################################################################\r
24 \r
25 import geompy\r
26 import salome\r
27 import os\r
28 import math\r
29 \r
30 #Sketcher_1 creation\r
31 Sketcher_1 = geompy.MakeSketcher("Sketcher:F 100 -57.7:TT 100 57.7:TT 0 115.47:TT -100 57.7:TT -100 -57.7:TT 0 -115.47:WW") \r
32 geompy.addToStudy(Sketcher_1, "Sketcher_1")\r
33 Face_1 = geompy.MakeFace(Sketcher_1, 1)\r
34 geompy.addToStudy(Face_1, "Face_1")\r
35 \r
36 #Line creation\r
37 Line_1 = geompy.MakeLineTwoPnt(geompy.MakeVertex(0,0,0), geompy.MakeVertex(0,0,100))\r
38 geompy.addToStudy(Line_1, "Line_1")\r
39 \r
40 #Prism creation\r
41 Prism_1 = geompy.MakePrismVecH(Face_1, Line_1, 100)\r
42 geompy.addToStudy(Prism_1, "Prism_1")\r
43 \r
44 #Sketcher_2 creation\r
45 Sketcher_2 = geompy.MakeSketcher("Sketcher:F 50 0:TT 80 0:TT 112 13:TT 112 48:TT 80 63:TT 80 90:TT 50 90:WW", [0,0,0, 1,0,0, 0,1,0]) \r
46 geompy.addToStudy(Sketcher_2, "Sketcher_2")\r
47 Face_2 = geompy.MakeFace(Sketcher_2, 1)\r
48 geompy.addToStudy(Face_2, "Face_2")\r
49 \r
50 #Revolution creation\r
51 Revolution_1 = geompy.MakeRevolution(Face_2, Line_1, 2*math.pi)\r
52 geompy.addToStudy(Revolution_1, "Revolution_1")\r
53 \r
54 #Common applying\r
55 Common_1 = geompy.MakeBoolean(Revolution_1, Prism_1, 1)\r
56 geompy.addToStudy(Common_1, "Common_1")\r
57 \r
58 #Explode Common_1 on edges\r
59 CommonExplodedListEdges = geompy.SubShapeAll(Common_1, geompy.ShapeType["EDGE"])\r
60 for i in range(0, len(CommonExplodedListEdges)):\r
61     name = "Edge_"+str(i+1)\r
62     geompy.addToStudyInFather(Common_1, CommonExplodedListEdges[i], name)\r
63 \r
64 #Fillet applying\r
65 #ID = geompy.GetSubShapeID(Common_1, CommonExplodedListEdges[0])\r
66 Fillet_1 = geompy.MakeFillet(Common_1, 10, geompy.ShapeType["EDGE"], [6])\r
67 geompy.addToStudy(Fillet_1, "Fillet_1")\r
68 \r
69 #Chamfer applying\r
70 Chamfer_1 = geompy.MakeChamferEdge(Fillet_1, 10, 10, 16, 50 )\r
71 geompy.addToStudy(Chamfer_1, "Chamfer_1")\r
72 \r
73 Chamfer_2 = geompy.MakeChamferEdge(Chamfer_1, 10, 10, 21, 31 )\r
74 geompy.addToStudy(Chamfer_2, "Chamfer_2")\r
75 \r
76 #Import of the shape from "slots.brep"\r
77 thePath = os.getenv("DATA_DIR")\r
78 theFileName = thePath + "/Shapes/Brep/slots.brep"\r
79 theShapeForCut = geompy.ImportBREP(theFileName)\r
80 geompy.addToStudy(theShapeForCut, "slot.brep_1")\r
81 \r
82 #Cut applying\r
83 Cut_1 = geompy.MakeBoolean(Chamfer_2, theShapeForCut, 2)\r
84 geompy.addToStudy(Cut_1, "Cut_1")\r
85 \r
86 salome.sg.updateObjBrowser(1)\r
87 \r