Version: 7.8.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
example4

AttributeSequenceOfInteger interface(creations/saving/restoring)
SALOMEDS methods : FindOrCreateAttribute FindComponent FindAttribute Open Add SaveAs AttributeSequenceOfInteger methods : Value, Remove, Length

# create AttributeSequenceOfInteger
#==========================================
A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, "AttributeSequenceOfInteger")
if A == None :
raise RuntimeError, "Can't create AttributeSequenceOfInteger attribute"
A = A._narrow(SALOMEDS.AttributeSequenceOfInteger)
if A == None :
raise RuntimeError, "Can't create AttributeSequenceOfInteger attribute"
A.Add(100)
A.Add(300)
A.Add(500)
A.Add(400)
A.Add(700)
A.Remove(3)
A.ChangeValue(4,500)
if A.Length() != 4:
print "Wrong length of SequenceOfInteger"
if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 400 or A.Value(4) != 700:
print "Wrong value of AttributeSequenceOfInteger"
# save / restore study
#=================================
str= os.getenv("TmpDir")
if str == None:
str = "/tmp"
file = str+"/test.hdf"
batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)
openedStudy=batchmode_geompy.myStudyManager.Open(file);
if openedStudy == None:
raise RuntimeError, "Can't open saved study!"
father = openedStudy.FindComponent("GEOM")
if father is None:
raise RuntimeError, "Geom component is not found! Wrong study is opened."
# find AttributeSequenceOfInteger
#======================================
res,A=father.FindAttribute("AttributeSequenceOfInteger")
if res == 0 or A == None:
raise RuntimeError, "Error: not found AttributeSequenceOfInteger"
A = A._narrow(SALOMEDS.AttributeSequenceOfInteger)
if A.Length() != 4:
print "Wrong length of SequenceOfInteger"
if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 400 or A.Value(4) != 700:
print "Wrong value of AttributeSequenceOfInteger"