NewLoadCase Method


Creates a new instance of a LoadCase 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 LoadCase NewLoadCase(
	string name,
	LoadNature nature,
	Category category
)
Visual Basic
Public Function NewLoadCase ( _
	name As String, _
	nature As LoadNature, _
	category As Category _
) As LoadCase
Visual C++
public:
LoadCase^ NewLoadCase(
	String^ name, 
	LoadNature^ nature, 
	Category^ category
)

Parameters

name
Type: System String
The not empty name for the Load Case Element to create.
nature
Type: Autodesk.Revit.DB.Structure LoadNature
The Load Case nature.
category
Type: Autodesk.Revit.DB Category
The Load Case category.

Return Value

If successful, NewLoadCase and there isn't the Load Case Element with the same name returns an object for the newly created LoadCase. If such element exist and match desired one (has the same nature and number), returns existing element. Otherwise a null reference ( Nothing in Visual Basic) is returned.

Examples

Copy C#
LoadCase CreateLoadCase(Autodesk.Revit.DB.Document document, Category category, LoadNature nature)
{
    // Create a load case
    // Category should be of type OST_LoadCases
    LoadCase loadCase = document.Create.NewLoadCase("new case", nature, category);
    if (null == loadCase)
    {
        throw new Exception("Create a new load case failed.");
    }

    // Give the user some information
    TaskDialog.Show("Revit","Successfully created a load case.");

    return loadCase;
}
Copy VB.NET
Private Function CreateLoadCase(document As Autodesk.Revit.DB.Document, category As Category, nature As LoadNature) As LoadCase
    ' Create a load case
    ' Category should be of type OST_LoadCases
    Dim loadCase As LoadCase = document.Create.NewLoadCase("new case", nature, category)
    If loadCase Is Nothing Then
        Throw New Exception("Create a new load case failed.")
    End If

    ' Give the user some information
    TaskDialog.Show("Revit", "Successfully created a load case.")

    Return loadCase
End Function

Exceptions

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

See Also