Example Usage

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

def runClassDemo_Solution2():
    #Get all results called bob and set the expression to SX.
    AllBobs = DesignAssessment.SolutionSelections()[0].SolutionByRow(1).SolutionResults("Bob")
    for BobResultIter in AllBobs:
        print "Bob found at " + str(BobResultIter)
        BobResultIter.Expression = "SX"

def runClassDemo_Solution():
    #Get  the first entered upstream solution.
    UpstreamSoln = DesignAssessment.SolutionSelections()[0].SolutionByRow(1)
    
    #Get properties that identify this solution.
    print "Id = " + str(UpstreamSoln.Id)
    print "Type = " + str(UpstreamSoln.Type)
    
    #Get properties defined for this entry in the solution selection worksheet
    print "Time = " + str(UpstreamSoln.Time)
    print "Frequency = " + str(UpstreamSoln.Frequency)
    print "Phase = " + str(UpstreamSoln.Phase)
    print "Mode = " + str(UpstreamSoln.Mode)
    print "Coefficient = " + str(UpstreamSoln.Coefficient)
    print "Result File Path = " + str(UpstreamSoln.ResultFilePath)
    print "Units system used = " + str(UpstreamSoln.Units)
    
    #XML defined properties in the solution selection worksheet
    print "Number of Additional strings = " + str(UpstreamSoln.AdditionalSolutionDataCount)
    print "Additional strings = " + str(UpstreamSoln.AdditionalSolutionData())
    print "Additional string, col 1 = " + str(UpstreamSoln. AdditionalSolutionDataByColumn(1))
    
    #Create a new result object for this solution
    #this object can then be used directly to set expressions, etc.
    MyResult = UpstreamSoln.CreateSolutionResult()
    #Use the Name for identification, 
    #useful to obtain the results in another subroutine in python.
    MyBobResult = UpstreamSoln.CreateSolutionResult("Bob")
    MyFredResult = UpstreamSoln.CreateSolutionResult("Fred")
    My2ndBobResult = UpstreamSoln.CreateSolutionResult("Bob")

    #Define expression at same time as creating the result.
    MySXDefinedResult = UpstreamSoln.CreateSolutionResult("FredSX","sx")
runClassDemo_Solution()

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