NewLoadCombination Method


Creates a new instance of a LoadCombination element within the project.

Namespace: Autodesk.Revit.Creation
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)

Syntax

C#
public LoadCombination NewLoadCombination(
	string name,
	int typeInd,
	int stateInd,
	double[] factors,
	LoadCaseArray cases,
	LoadCombinationArray combinations,
	LoadUsageArray usages
)
Visual Basic
Public Function NewLoadCombination ( _
	name As String, _
	typeInd As Integer, _
	stateInd As Integer, _
	factors As Double(), _
	cases As LoadCaseArray, _
	combinations As LoadCombinationArray, _
	usages As LoadUsageArray _
) As LoadCombination
Visual C++
public:
LoadCombination^ NewLoadCombination(
	String^ name, 
	int typeInd, 
	int stateInd, 
	array<double>^ factors, 
	LoadCaseArray^ cases, 
	LoadCombinationArray^ combinations, 
	LoadUsageArray^ usages
)

Parameters

name
Type: System String
The not empty name for the Load Combination Element to create.
typeInd
Type: System Int32
LoadCombination Type Index: 0-Combination, 1-Envelope.
stateInd
Type: System Int32
LoadCombination State Index: 0-Servicebility, 1-Ultimate.
factors
Type: System Double
Factors array for Load Combination formula.
cases
Type: Autodesk.Revit.DB.Structure LoadCaseArray
Load Cases array for Load Combination formula.
combinations
Type: Autodesk.Revit.DB.Structure LoadCombinationArray
Load Combinations array for Load Combination formula.
usages
Type: Autodesk.Revit.DB.Structure LoadUsageArray
Load Usages array.

Return Value

If successful, NewLoadCombination and there isn't the Load Combination Element with the same name returns an object for the newly created LoadCombination. If such element exist and match desired one (has the same formula and the same usages set), returns existing element. Otherwise a null reference ( Nothing in Visual Basic) is returned.

Remarks

Factors and Load Combinations arrays have the same dimension (n). The Load Combination formula is equal to: factors[0]*cases[0]*factors[1]*cases[1]*. . . factors[n]*cases[n].

Examples

Copy C#
LoadCombination CreateLoadCombination(Autodesk.Revit.DB.Document document, LoadCaseArray loadCases, LoadUsageArray loadUsages)
{
    // Create the factor array for load combination creation
    double[] factorArray = new double[loadCases.Size];
    for (int ii = 0; ii < loadCases.Size; ii++)
    {
        factorArray[ii] = ii + 1;
    }

    // Create a new load combination
    int typeInd = 0;    // Combination
    int stateInd = 0;   // Servicebility
    LoadCombinationArray combinations = new LoadCombinationArray();

    LoadCombination loadCombination = document.Create.NewLoadCombination("New combination",
                                                        typeInd, stateInd, factorArray, loadCases, 
                                                        combinations, loadUsages);
    if (null == loadCombination)
    {
        throw new Exception("Create a load combination failed.");
    }

    // Give the user some information
    TaskDialog.Show("Revit","Load combination created successfully.");

    return loadCombination;
}
Copy VB.NET
Private Function CreateLoadCombination(document As Autodesk.Revit.DB.Document, loadCases As LoadCaseArray, loadUsages As LoadUsageArray) As LoadCombination
    ' Create the factor array for load combination creation
    Dim factorArray As Double() = New Double(loadCases.Size - 1) {}
    For ii As Integer = 0 To loadCases.Size - 1
        factorArray(ii) = ii + 1
    Next

    ' Create a new load combination
    Dim typeInd As Integer = 0
    ' Combination
    Dim stateInd As Integer = 0
    ' Servicebility
    Dim combinations As New LoadCombinationArray()

    Dim loadCombination As LoadCombination = document.Create.NewLoadCombination("New combination", typeInd, stateInd, factorArray, loadCases, combinations, _
        loadUsages)
    If loadCombination Is Nothing Then
        Throw New Exception("Create a load combination failed.")
    End If

    ' Give the user some information
    TaskDialog.Show("Revit", "Load combination created successfully.")

    Return loadCombination
End Function

Exceptions

Exception Condition
Autodesk.Revit.Exceptions InvalidOperationException If the product is not Revit Structure.

See Also