Work with Solution Combinations

Goal: Create a solution combination object combining many environments.

Code:

# get the environments, an alternative would be via Model.Analyses
envs = DataModel.GetObjectsByType(DataModelObjectCategory.Analysis)

# create a solution combination object; By default it will come with 1 base case and 1 combination
sc = Model.AddSolutionCombination()

# definition object holds all the data
scdef = sc.Definition

# Any property on a base case can be set using an index and value
scdef.SetBaseCaseAnalysis(0, envs[0])
scdef.SetBaseCaseTime(0,1)

# Add more base cases as you desire
scdef.AddBaseCase()
scdef.SetBaseCaseAnalysis(1, envs[1])

# You can even pass in the Base Case settings to the constructor (Arguments are name, analysis, time)
scdef.AddBaseCase("BC 3", envs[1], 2)

# Any property on a load combination can be set using an index and value
scdef.SetLoadCombinationType(0,1)

# Add more load combinations as you desire
scdef.AddLoadCombination()
scdef.SetLoadCombinationName(1, "LC2")

# You can even pass in the Load Combination settings to the constructor (Arguments are name, type)
scdef.AddLoadCombination("LC3", 1)

# Coefficients are set using two indices and a value
scdef.SetCoefficient(0, 0, 2)
scdef.SetCoefficient(0, 2, 1)
scdef.SetCoefficient(1, 0, -0.5)
scdef.SetCoefficient(1, 1, 0.75)
scdef.SetCoefficient(2, 0, -1)
scdef.SetCoefficient(2, 2, 1.5)

#Once fully defined, add results and evaluate
sc.AddEquivalentStress()
sc.EvaluateAllResults()