1 #####################################################################
3 #Auhtor :MASLOV Eugeny, KOVALTCHUK Alexey
4 #####################################################################
14 print "Sketcher creation..."
15 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")
16 geompy.addToStudy(Sketcher_1, "Sketcher_1")
17 Face_1 = geompy.MakeFace(Sketcher_1, 1)
18 geompy.addToStudy(Face_1, "Face_1")
21 print "Line creation..."
22 Line_1 = geompy.MakeLineTwoPnt(geompy.MakeVertex(0,0,0), geompy.MakeVertex(0,0,100))
23 geompy.addToStudy(Line_1, "Line_1")
26 print "Prism creation..."
27 Prism_1 = geompy.MakePrismVecH(Face_1, Line_1, 100)
28 geompy.addToStudy(Prism_1, "Prism_1")
31 print "Sketcher creation..."
32 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])
33 geompy.addToStudy(Sketcher_2, "Sketcher_2")
34 Face_2 = geompy.MakeFace(Sketcher_2, 1)
35 geompy.addToStudy(Face_2, "Face_2")
38 print "Revolution creation..."
39 Revolution_1 = geompy.MakeRevolution(Face_2, Line_1, 2*math.pi)
40 geompy.addToStudy(Revolution_1, "Revolution_1")
43 print "Common of Revolution and Prism..."
44 Common_1 = geompy.MakeBoolean(Revolution_1, Prism_1, 1)
45 geompy.addToStudy(Common_1, "Common_1")
47 #Explode Common_1 on edges
48 CommonExplodedListEdges = geompy.SubShapeAll(Common_1, geompy.ShapeType["EDGE"])
49 for i in range(0, len(CommonExplodedListEdges)):
50 name = "Edge_"+str(i+1)
51 geompy.addToStudyInFather(Common_1, CommonExplodedListEdges[i], name)
54 print "Fillet creation..."
55 Fillet_1 = geompy.MakeFillet(Common_1, 10, geompy.ShapeType["EDGE"], [6])
56 geompy.addToStudy(Fillet_1, "Fillet_1")
59 print "Chamfer creation..."
60 Chamfer_1 = geompy.MakeChamferEdge(Fillet_1, 10, 10, 16, 50 )
61 geompy.addToStudy(Chamfer_1, "Chamfer_1")
62 Chamfer_2 = geompy.MakeChamferEdge(Chamfer_1, 10, 10, 21, 31 )
63 geompy.addToStudy(Chamfer_2, "Chamfer_2")
65 #Import of the shape from "slots.brep"
66 print "Import multi-rotation from the DATA_DIR/Shapes/Brep/slots.brep"
67 thePath = os.getenv("DATA_DIR")
68 theFileName = thePath + "/Shapes/Brep/slots.brep"
69 theShapeForCut = geompy.ImportBREP(theFileName)
70 geompy.addToStudy(theShapeForCut, "slot.brep_1")
74 Cut_1 = geompy.MakeBoolean(Chamfer_2, theShapeForCut, 2)
75 Cut_1_ID = geompy.addToStudy(Cut_1, "Cut_1")
78 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
81 shape_mesh = salome.IDToObject( Cut_1_ID )
82 smesh.SetCurrentStudy(salome.myStudy)
83 mesh = smesh.CreateMesh(shape_mesh)
84 smeshgui = salome.ImportComponentGUI("SMESH")
85 smeshgui.Init(salome.myStudyId)
86 idmesh = salome.ObjectToID(mesh)
87 smeshgui.SetName( idmesh, "Nut" )
90 print "-------------------------- Average length"
92 hAvLength = smesh.CreateHypothesis( "LocalLength", "libStdMeshersEngine.so" )
93 hAvLength.SetLength( theAverageLength )
94 print hAvLength.GetName()
95 print hAvLength.GetId()
96 smeshgui.SetName(salome.ObjectToID(hAvLength), "AverageLength_5")
98 print "-------------------------- MaxElementArea"
99 theMaxElementArea = 20
100 hArea20 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
101 hArea20.SetMaxElementArea( theMaxElementArea )
102 print hArea20.GetName()
103 print hArea20.GetId()
104 print hArea20.GetMaxElementArea()
105 smeshgui.SetName(salome.ObjectToID(hArea20), "MaxElementArea_20")
107 print "-------------------------- MaxElementVolume"
108 theMaxElementVolume = 150
109 hVolume150 = smesh.CreateHypothesis( "MaxElementVolume", "libStdMeshersEngine.so" )
110 hVolume150.SetMaxElementVolume( theMaxElementVolume )
111 print hVolume150.GetName()
112 print hVolume150.GetId()
113 print hVolume150.GetMaxElementVolume()
114 smeshgui.SetName(salome.ObjectToID(hVolume150), "MaxElementVolume_150")
116 mesh.AddHypothesis(shape_mesh, hAvLength)
117 mesh.AddHypothesis(shape_mesh, hArea20)
118 mesh.AddHypothesis(shape_mesh, hVolume150)
120 print "-------------------------- Regular_1D"
122 algoReg1D = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
123 listHyp = algoReg1D.GetCompatibleHypothesis()
126 print algoReg1D.GetName()
127 print algoReg1D.GetId()
128 smeshgui.SetName(salome.ObjectToID(algoReg1D), "Wire discretisation")
130 print "-------------------------- MEFISTO_2D"
131 algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
132 listHyp = algoMef.GetCompatibleHypothesis()
135 print algoMef.GetName()
136 print algoMef.GetId()
137 smeshgui.SetName(salome.ObjectToID(algoMef), "Triangle (Mefisto)")
139 print "-------------------------- NETGEN_3D"
141 algoNg = smesh.CreateHypothesis( "NETGEN_3D", "libNETGENEngine.so" )
142 print algoNg.GetName()
144 smeshgui.SetName(salome.ObjectToID(algoNg), "Tetrahedron (NETGEN)")
145 mesh.AddHypothesis(shape_mesh, algoReg1D)
146 mesh.AddHypothesis(shape_mesh, algoMef)
147 mesh.AddHypothesis(shape_mesh, algoNg)
149 print "-------------------------- compute the mesh of the mechanic piece"
150 smesh.Compute(mesh,shape_mesh)
152 print "Information about the Nut:"
153 print "Number of nodes : ", mesh.NbNodes()
154 print "Number of edges : ", mesh.NbEdges()
155 print "Number of faces : ", mesh.NbFaces()
156 print "Number of triangles : ", mesh.NbTriangles()
157 print "Number of quadrangles : ", mesh.NbQuadrangles()
158 print "Number of volumes : ", mesh.NbVolumes()
159 print "Number of tetrahedrons: ", mesh.NbTetras()
161 salome.sg.updateObjBrowser(1)