00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 import geompy
00030 import salome
00031 import smesh
00032 import os
00033 import math
00034
00035
00036 print "Sketcher creation..."
00037 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")
00038 geompy.addToStudy(Sketcher_1, "Sketcher_1")
00039 Face_1 = geompy.MakeFace(Sketcher_1, 1)
00040 geompy.addToStudy(Face_1, "Face_1")
00041
00042
00043 print "Line creation..."
00044 Line_1 = geompy.MakeLineTwoPnt(geompy.MakeVertex(0,0,0), geompy.MakeVertex(0,0,100))
00045 geompy.addToStudy(Line_1, "Line_1")
00046
00047
00048 print "Prism creation..."
00049 Prism_1 = geompy.MakePrismVecH(Face_1, Line_1, 100)
00050 geompy.addToStudy(Prism_1, "Prism_1")
00051
00052
00053 print "Sketcher creation..."
00054 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])
00055 geompy.addToStudy(Sketcher_2, "Sketcher_2")
00056 Face_2 = geompy.MakeFace(Sketcher_2, 1)
00057 geompy.addToStudy(Face_2, "Face_2")
00058
00059
00060 print "Revolution creation..."
00061 Revolution_1 = geompy.MakeRevolution(Face_2, Line_1, 2*math.pi)
00062 geompy.addToStudy(Revolution_1, "Revolution_1")
00063
00064
00065 print "Common of Revolution and Prism..."
00066 Common_1 = geompy.MakeBoolean(Revolution_1, Prism_1, 1)
00067 geompy.addToStudy(Common_1, "Common_1")
00068
00069
00070 CommonExplodedListEdges = geompy.SubShapeAll(Common_1, geompy.ShapeType["EDGE"])
00071 for i in range(0, len(CommonExplodedListEdges)):
00072 name = "Edge_"+str(i+1)
00073 geompy.addToStudyInFather(Common_1, CommonExplodedListEdges[i], name)
00074
00075
00076 print "Fillet creation..."
00077 Fillet_1 = geompy.MakeFillet(Common_1, 10, geompy.ShapeType["EDGE"], [5])
00078 geompy.addToStudy(Fillet_1, "Fillet_1")
00079
00080
00081 print "Chamfer creation..."
00082 Chamfer_1 = geompy.MakeChamferEdge(Fillet_1, 10, 10, 16, 50 )
00083 geompy.addToStudy(Chamfer_1, "Chamfer_1")
00084 Chamfer_2 = geompy.MakeChamferEdge(Chamfer_1, 10, 10, 21, 31 )
00085 geompy.addToStudy(Chamfer_2, "Chamfer_2")
00086
00087
00088 print "Import multi-rotation from the DATA_DIR/Shapes/Brep/slots.brep"
00089 thePath = os.getenv("DATA_DIR")
00090 theFileName = os.path.join( thePath,"Shapes","Brep","slots.brep")
00091 theShapeForCut = geompy.ImportBREP(theFileName)
00092 geompy.addToStudy(theShapeForCut, "slot.brep_1")
00093
00094
00095 print "Cut..."
00096 Cut_1 = geompy.MakeBoolean(Chamfer_2, theShapeForCut, 2)
00097 Cut_1_ID = geompy.addToStudy(Cut_1, "Cut_1")
00098
00099
00100
00101 smesh.SetCurrentStudy(salome.myStudy)
00102
00103
00104 shape_mesh = salome.IDToObject( Cut_1_ID )
00105
00106 mesh = smesh.Mesh(shape_mesh, "Nut")
00107
00108
00109 print "-------------------------- Average length"
00110 theAverageLength = 5
00111 algoReg1D = mesh.Segment()
00112 hAvLength = algoReg1D.LocalLength(theAverageLength)
00113 print hAvLength.GetName()
00114 print hAvLength.GetId()
00115 print hAvLength.GetLength()
00116 smesh.SetName(hAvLength, "AverageLength_"+str(theAverageLength))
00117
00118 print "-------------------------- MaxElementArea"
00119 theMaxElementArea = 20
00120 algoMef = mesh.Triangle(smesh.MEFISTO)
00121 hArea = algoMef.MaxElementArea( theMaxElementArea )
00122 print hArea.GetName()
00123 print hArea.GetId()
00124 print hArea.GetMaxElementArea()
00125 smesh.SetName(hArea, "MaxElementArea_"+str(theMaxElementArea))
00126
00127 print "-------------------------- MaxElementVolume"
00128 theMaxElementVolume = 150
00129 algoNg = mesh.Tetrahedron(smesh.NETGEN)
00130 hVolume = algoNg.MaxElementVolume( theMaxElementVolume )
00131 print hVolume.GetName()
00132 print hVolume.GetId()
00133 print hVolume.GetMaxElementVolume()
00134 smesh.SetName(hVolume, "MaxElementVolume_"+str(theMaxElementVolume))
00135
00136
00137 print "-------------------------- compute the mesh of the mechanic piece"
00138 mesh.Compute()
00139
00140 print "Information about the Nut:"
00141 print "Number of nodes : ", mesh.NbNodes()
00142 print "Number of edges : ", mesh.NbEdges()
00143 print "Number of faces : ", mesh.NbFaces()
00144 print "Number of triangles : ", mesh.NbTriangles()
00145 print "Number of quadrangles : ", mesh.NbQuadrangles()
00146 print "Number of volumes : ", mesh.NbVolumes()
00147 print "Number of tetrahedrons: ", mesh.NbTetras()
00148
00149 salome.sg.updateObjBrowser(1)