Example Usage

The following example can be used as a basis of either the solve or evaluate script.

def runClassDemo_AttributeGroups():
    #Loop around all attribute group objects.
    for AGIterator in DesignAssessment.AttributeGroups():
        #Attribute Group info
        print "Name = " + AGIterator.TreeName
        print "Type = " + AGIterator.XmlType
        print "Subtype = " + AGIterator.XmlSubType
        
        #Obtaining contained attributes 
        print "No of Attributes = " + str(AGIterator.AttributeCount)
        Index = 0
        for AttributeIterator in AGIterator.Attributes():
            #Get the name of this attribute
            AName = AttributeIterator.AttributeName
            #Get the attribute, based on the index
            AttributeMethod1 = AGIterator.Attribute(Index)
            #Get the attribute, based on the Name, it's easier to look up by name.
            AttributeMethod2 = AGIterator.Attribute(AName)
            print "Attribute Name: " + AName
            print "Check names are the same: " + str(AName == AttributeMethod1.AttributeName)
            print "Are attrib. objects the same: " + str(AttributeMethod1 == AttributeMethod2)
            #Add to the index (there are more concise ways of doing this in a loop)
            Index = Index + 1
runClassDemo_AttributeGroups()

Release 18.2 - © ANSYS, Inc. All rights reserved.