Back to index

salome-geom  6.5.0
GEOM_Nut.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 #####################################################################
00025 #Created                :17/02/2005
00026 #Auhtor                 :MASLOV Eugeny, KOVALTCHUK Alexey 
00027 #####################################################################
00028 #
00029 import geompy
00030 import salome
00031 import os
00032 import math
00033 
00034 #Sketcher_1 creation
00035 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") 
00036 geompy.addToStudy(Sketcher_1, "Sketcher_1")
00037 Face_1 = geompy.MakeFace(Sketcher_1, 1)
00038 geompy.addToStudy(Face_1, "Face_1")
00039 
00040 #Line creation
00041 Line_1 = geompy.MakeLineTwoPnt(geompy.MakeVertex(0,0,0), geompy.MakeVertex(0,0,100))
00042 geompy.addToStudy(Line_1, "Line_1")
00043 
00044 #Prism creation
00045 Prism_1 = geompy.MakePrismVecH(Face_1, Line_1, 100)
00046 geompy.addToStudy(Prism_1, "Prism_1")
00047 
00048 #Sketcher_2 creation
00049 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]) 
00050 geompy.addToStudy(Sketcher_2, "Sketcher_2")
00051 Face_2 = geompy.MakeFace(Sketcher_2, 1)
00052 geompy.addToStudy(Face_2, "Face_2")
00053 
00054 #Revolution creation
00055 Revolution_1 = geompy.MakeRevolution(Face_2, Line_1, 2*math.pi)
00056 geompy.addToStudy(Revolution_1, "Revolution_1")
00057 
00058 #Common applying
00059 Common_1 = geompy.MakeBoolean(Revolution_1, Prism_1, 1)
00060 geompy.addToStudy(Common_1, "Common_1")
00061 
00062 #Explode Common_1 on edges
00063 CommonExplodedListEdges = geompy.SubShapeAll(Common_1, geompy.ShapeType["EDGE"])
00064 for i in range(0, len(CommonExplodedListEdges)):
00065     name = "Edge_"+str(i+1)
00066     geompy.addToStudyInFather(Common_1, CommonExplodedListEdges[i], name)
00067 
00068 #Fillet applying
00069 #ID = geompy.GetSubShapeID(Common_1, CommonExplodedListEdges[0])
00070 Fillet_1 = geompy.MakeFillet(Common_1, 10, geompy.ShapeType["EDGE"], [5])
00071 geompy.addToStudy(Fillet_1, "Fillet_1")
00072 
00073 #Chamfer applying
00074 Chamfer_1 = geompy.MakeChamferEdge(Fillet_1, 10, 10, 16, 50 )
00075 geompy.addToStudy(Chamfer_1, "Chamfer_1")
00076 
00077 Chamfer_2 = geompy.MakeChamferEdge(Chamfer_1, 10, 10, 21, 31 )
00078 geompy.addToStudy(Chamfer_2, "Chamfer_2")
00079 
00080 #Import of the shape from "slots.brep"
00081 thePath = os.getenv("DATA_DIR")
00082 theFileName = thePath + "/Shapes/Brep/slots.brep"
00083 theShapeForCut = geompy.ImportBREP(theFileName)
00084 geompy.addToStudy(theShapeForCut, "slot.brep_1")
00085 
00086 #Cut applying
00087 Cut_1 = geompy.MakeBoolean(Chamfer_2, theShapeForCut, 2)
00088 geompy.addToStudy(Cut_1, "Cut_1")
00089 
00090 salome.sg.updateObjBrowser(1)
00091