Salome HOME
0020654: [CEA 386] GetType() function
[modules/geom.git] / doc / salome / gui / GEOM / input / tui_import_export.doc
1 /*!
2
3 \page tui_import_export_page Import/Export
4 \code
5 import geompy
6 import salome
7
8 # Example of import from IGES using various formats
9
10 # get a path to SAMPLES_SRC
11 import os
12 thePath = os.getenv("DATA_DIR")
13 # create filenames
14 theFileName1 = thePath + "/Shapes/Iges/boite-3Dipsos_m.igs"
15 theFileName2 = thePath + "/Shapes/Iges/boite-3Dipsos_mm.igs"
16 #print "thePath = ", thePath
17
18 # get units from files
19 UnitName1 = geompy.GetIGESUnit(theFileName1)
20 UnitName2 = geompy.GetIGESUnit(theFileName2)
21 print "UnitName1 = ", UnitName1
22 print "UnitName2 = ", UnitName2
23
24 # import shapes
25 Shape1 = geompy.ImportIGES(theFileName1)
26 Shape2 = geompy.ImportIGES(theFileName2)
27 Shape3 = geompy.Import(theFileName2,"IGES_SCALE")
28 [Xmin1,Xmax1, Ymin1,Ymax1, Zmin1,Zmax1] = geompy.BoundingBox(Shape1)
29 [Xmin2,Xmax2, Ymin2,Ymax2, Zmin2,Zmax2] = geompy.BoundingBox(Shape2)
30 [Xmin3,Xmax3, Ymin3,Ymax3, Zmin3,Zmax3] = geompy.BoundingBox(Shape3)
31 geompy.addToStudy(Shape1, "3Dipsos_m")
32 geompy.addToStudy(Shape2, "3Dipsos_mm")
33 geompy.addToStudy(Shape3, "3Dipsos_mm_scaled")
34 d1 = (Xmax1-Xmin1)*(Xmax1-Xmin1) + (Ymax1-Ymin1)*(Ymax1-Ymin1) + (Zmax1-Zmin1)*(Zmax1-Zmin1)
35 d2 = (Xmax2-Xmin2)*(Xmax2-Xmin2) + (Ymax2-Ymin2)*(Ymax2-Ymin2) + (Zmax2-Zmin2)*(Zmax2-Zmin2)
36 d3 = (Xmax3-Xmin3)*(Xmax3-Xmin3) + (Ymax3-Ymin3)*(Ymax3-Ymin3) + (Zmax3-Zmin3)*(Zmax3-Zmin3)
37 import math
38 dd32 = math.sqrt(d3/d2)
39 dd12 = math.sqrt(d1/d2)
40 dd31 = math.sqrt(d3/d1)
41 # values dd31, dd12 and dd31 can be using for checking
42 print "dd32 = ",dd32,"  dd12 = ",dd12,"  dd31 = ",dd31
43 \endcode
44
45 */