if box is None :
raise RuntimeError, "box was not found! Wrong
ID is used."
SObject FindObjectIOR
( in ID aObjectIOR
)
Find the SObject of the result on imported MED file
by it's IOR:
theResult = myVisu.ImportFile(medFile)
aSObj = myStudy.FindObjectIOR(theResult.GetID())
SObject
FindObjectByPath ( in string thePath )
Find SObject by path to it:
# create new auxiliary component
aComponent = myStudyBuilder.NewComponent("Virtual Component")
# create auxiliary subtree
aPath = "/Virtual Component/Case1"
myStudyBuilder.AddDirectory(aPath)
aSObj = myStudy.FindObjectByPath(aPath)
void SetContext ( in string thePath) /
string GetContext ()
Set context of the study to the created case and get it for printing:
aComponent = myStudyBuilder.NewComponent("User data")
anAttr = aBuilder.FindOrCreateAttribute(aComponent, "AttributeName")
anAttrName = anAttr._narrow(SALOMEDS.AttributeName)
anAttrName.SetValue("User data")
#Add a new case 'Case1' to the component 'User data'
aBuilder.AddDirectory("/User data/Case1")
#Set a study context to '/User data/Case1'
aStudy.SetContext("/User data/Case1")
#Print the current study context
print aStudy.GetContext()
#result: "/User data/Case1".
ChildIterator
NewChildIterator ( in SObject aSO )
Import med file and print all mesh names that this file includes
(mesh is a child of the result of imported file):
# define file name
aFileName = datadir + "fra.med"
# import file in visu module and get result
theVisu = batchmode_visu.myVisu
aResult = theVisu.ImportFile(aFileName)
if aResult is None : raise RuntimeError, "Error"
else : print "OK"
# get current study and its' SObject
myLocalStudy = theVisu.GetCurrentStudy()
aSObj = myLocalStudy.FindObjectIOR(aResult.GetID())
if aSObj is None : raise RuntimeError, "Error"
else : print "OK"
# create iterator by SObject of the current study
aMeshIter = myLocalStudy.NewChildIterator(aSObj);
# iterating in the current study (with the help of created iterator)
to find all mesh names
while aMeshIter.More() :
aMeshSObj = aMeshIter.Value()
aMeshIter.Next()
anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
if anAttr is None :
aMeshSObj
= aMeshIter.Value()
aMeshIter.Next()
anAttr
= aMeshSObj.FindAttribute("AttributeName")[1]
anAttr = anAttr._narrow(SALOMEDS.AttributeName);
aMeshName = anAttr.Value()
print " ", aMeshName
SComponentIterator
NewComponentIterator ()
Find the number an names of all components in the study:
aCompItr = myStudy.NewComponentIterator()
compNb = 0
while aCompItr.More():
aComp = aCompItr.Value()
aName = aComp.ComponentDataType()
print "Component name = ", aName
compNb += 1
aCompItr.Next()
StudyBuilder
NewBuilder ()