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, "AttributeTableOfInteger")
\r
14 raise RuntimeError, "Can't create AttributeTableOfInteger attribute"
\r
15 A = A._narrow(SALOMEDS.AttributeTableOfInteger)
\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
62 for i in range(1, rnb):
\r
63 b=A.GetRow(i)
\r
64 print b
\r
66 cnb = A.GetNbColumns()
\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
83 str= os.getenv("TmpDir")
\r
85 str = "/tmp"
\r
86 file = str+"/test.hdf"
\r
88 print " ------- We will save to", file, "-----------"
\r
90 batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)
\r
92 #--------------------------------------------------------------------------#
\r
93 #---------------------------- Open file -----------------------------------#
\r
94 #--------------------------------------------------------------------------#
\r
96 print" -------------- Open " + file + "-------------- "
\r
98 openedStudy=batchmode_geompy.myStudyManager.Open(file)
\r
99 if openedStudy == None:
\r
100 raise RuntimeError, "Can't open saved study!"
\r
102 father = openedStudy.FindComponent("GEOM")
\r
104 raise RuntimeError, "Geom component is not found! Wrong study is opened."
\r
106 # --- check attribute ---
\r
108 res,A=father.FindAttribute("AttributeTableOfInteger")
\r
109 if res == 0 or A == None:
\r
110 raise RuntimeError, "Error: not found AttributeTableOfInteger"
\r
112 A = A._narrow(SALOMEDS.AttributeTableOfInteger)
\r
115 print "Common title : ",A.GetTitle()
\r
116 print "Rows titles : ", A.GetRowTitles()
\r
117 rnb = A.GetNbRows()
\r
118 for i in range(1, rnb):
\r
119 b=A.GetRow(i)
\r
120 print b
\r
122 cnb = A.GetNbColumns()
\r
123 print "Columns title : ", A.GetColumnTitles()
\r
124 for i in range(1, cnb):
\r
125 b=A.GetColumn(i)
\r
126 print b
\r
128 titles=["ff","ss","tt"]
\r
129 A.SetRowTitles(titles)
\r
130 print "Rows titles : ", A.GetRowTitles()
\r
132 titles=["ww","zz","cc"]
\r
133 A.SetColumnTitles(titles)
\r
134 print "Column titles : ", A.GetColumnTitles()
\r