1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
\r
3 <!-- hennerik CVSweb $Revision$ -->
\r
4 <TITLE>Exemple</TITLE></HEAD>
\r
5 <BODY BGCOLOR="#eeeeee">
\r
7 #^ SALOMEDS methods : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open^
\r
8 #^ Attribute methods : GetValue, GetNbColumns, AddColumn, SetRowTitles, PutValue, GetColumn, GetColumnTitles, GetTitle, SetRow, GetRowTitles, SetColumnTitles, SetColumn, GetRow, GetNbRows, SetColumnTitle, AddRow, SetTitle, SetRowTitle^
\r
10 # create AttributeReal
\r
11 #===============================================
\r
12 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, "AttributeTableOfReal")
\r
14 raise RuntimeError, "Can't create AttributeTableOfReal attribute"
\r
15 A = A._narrow(SALOMEDS.AttributeTableOfReal)
\r
39 # change attribute values
\r
40 print "A.GetValue(2,2) = ", A.GetValue(2,2)
\r
41 print "A.PutValue(2,2,625323)"
\r
42 A.PutValue(625323,2,2)
\r
43 print "A.GetValue(2,2) = ", A.GetValue(2,2)
\r
47 A.SetTitle("TEST")
\r
49 A.SetRowTitle(1,"FR")
\r
50 A.SetRowTitle(2,"SR")
\r
51 A.SetRowTitle(3,"TR")
\r
53 A.SetColumnTitle(1,"FC")
\r
54 A.SetColumnTitle(2,"SC")
\r
55 A.SetColumnTitle(3,"TC")
\r
59 print "Common title : ",A.GetTitle()
\r
60 print "Rows titles : ", A.GetRowTitles()
\r
61 rnb = A.GetNbRows() + 1
\r
62 for i in range(1, rnb):
\r
63 b=A.GetRow(i)
\r
64 print b
\r
66 cnb = A.GetNbColumns() + 1
\r
67 print "Columns title : ", A.GetColumnTitles()
\r
68 for i in range(1, cnb):
\r
69 b=A.GetColumn(i)
\r
70 print b
\r
73 #titles=["11","12","13"]
\r
74 #A.SetRowTitles(titles)
\r
75 #titles=["21","22","23"]
\r
76 #A.SetRowTitles(2,titles)
\r
77 #titles=["31","32","33"]
\r
78 #A.SetRowTitles(3,titles)
\r
80 #--------------------------------------------------------------------------#
\r
81 #------------------------ save the study ----------------------------------#
\r
82 #--------------------------------------------------------------------------#
\r
84 str= os.getenv("TmpDir")
\r
86 str = "/tmp"
\r
87 file = str+"/test.hdf"
\r
89 print " ------- We will save to", file, "-----------"
\r
91 batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)
\r
93 #--------------------------------------------------------------------------#
\r
94 #---------------------------- Open file -----------------------------------#
\r
95 #--------------------------------------------------------------------------#
\r
97 print" -------------- Open " + file + "-------------- "
\r
99 openedStudy = batchmode_geompy.myStudyManager.Open(file)
\r
100 if openedStudy == None:
\r
101 raise RuntimeError, "Can't open saved study!"
\r
103 father = openedStudy.FindComponent("GEOM")
\r
105 raise RuntimeError, "Geom component is not found! Wrong study is opened."
\r
107 # --- check attribute ---
\r
109 res,A=father.FindAttribute("AttributeTableOfReal")
\r
110 if res == 0 or A == None:
\r
111 raise RuntimeError, "Error: not found AttributeTableOfReal"
\r
113 A = A._narrow(SALOMEDS.AttributeTableOfReal)
\r
116 print "Common title : ",A.GetTitle()
\r
117 print "Rows titles : ", A.GetRowTitles()
\r
118 rnb = A.GetNbRows() + 1
\r
119 for i in range(1, rnb):
\r
120 b=A.GetRow(i)
\r
121 print b
\r
123 cnb = A.GetNbColumns() + 1
\r
124 print "Columns title : ", A.GetColumnTitles()
\r
125 for i in range(1, cnb):
\r
126 b=A.GetColumn(i)
\r
127 print b
\r
129 titles=["ff","ss","tt"]
\r
130 A.SetRowTitles(titles)
\r
131 print "Rows titles : ", A.GetRowTitles()
\r
133 titles=["ww","zz","cc"]
\r
134 A.SetColumnTitles(titles)
\r
135 print "Column titles : ", A.GetColumnTitles()
\r