SALOME documentation central

example9

AttributeSelectable interface(creations/saving/restoring)
SALOMEDS methods: FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open
Attribute methods: SetSelectable, IsSelectable

#              create    AttributeSelectable  
#===========================================================
A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, "AttributeSelectable")
if A == None :
        raise  RuntimeError, "Can't create AttributeSelectable attribute"
A = A._narrow(SALOMEDS.AttributeSelectable)

if A == None :
        raise  RuntimeError, "Can't create AttributeSelectable attribute"

A.SetSelectable(1)

if A.IsSelectable() == 0:
        "Error: wrong value of AttributeSelectable"


#      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   AttributeSelectable
#============================================================

res,A=father.FindAttribute("AttributeSelectable")
if res == 0 or A == None:
        raise  RuntimeError, "Error:  not found AttributeSelectable"

A = A._narrow(SALOMEDS.AttributeSelectable)

if A == None :
        raise  RuntimeError, "Can't create AttributeSelectable attribute"

if A.IsSelectable() == 0:
        "Error: wrong value of AttributeSelectable"


Copyright © 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS