This object represents a load case within the project.
Namespace: Autodesk.Revit.DB.Structure
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Syntax
Examples

private void LoadCaseInfomation(Document document, LoadCase loadCase) { string loadCaseNumber; //Store the load cases number StringBuilder information = new StringBuilder(10); // first get all the load case categories in a list List<Category> loadCaseCategories = new List<Category>(); GetLoadCaseCategories(document, ref loadCaseCategories); //get the load case name information.Append("\nCase Name: " + loadCase.Name); //get the number of the load case Parameter caseNumber = loadCase.get_Parameter(BuiltInParameter.LOAD_CASE_NUMBER); if (null == caseNumber) { loadCaseNumber = ""; } else { loadCaseNumber = caseNumber.AsInteger().ToString(); } information.Append("\nCase Number: " + loadCaseNumber); //get the category of the load case Parameter caseCategoryid = loadCase.get_Parameter(BuiltInParameter.LOAD_CASE_CATEGORY); Autodesk.Revit.DB.ElementId loadCaseCategoryId = caseCategoryid.AsElementId(); information.Append("\nCategory: " + GetCategoryName(loadCaseCategoryId, loadCaseCategories)); //get the nature of load case Parameter caseNatureId = loadCase.get_Parameter(BuiltInParameter.LOAD_CASE_NATURE); Autodesk.Revit.DB.ElementId loadCaseNatureId = caseNatureId.AsElementId(); LoadNature loadNature = document.GetElement(loadCaseNatureId) as LoadNature; information.Append("\nNature: " + loadNature.Name + "\n"); //show the information to the user TaskDialog.Show("Revit",information.ToString()); } private void GetLoadCaseCategories(Document document, ref List<Category> loadCaseCategories) { //get all the categories of load cases Categories categories = document.Settings.Categories; Category caseCategory = categories.get_Item(BuiltInCategory.OST_LoadCases); CategoryNameMap categoryNameMap = caseCategory.SubCategories; System.Collections.IEnumerator iter = categoryNameMap.GetEnumerator(); iter.Reset(); while (iter.MoveNext()) { Category temp = iter.Current as Category; if (null != temp) { loadCaseCategories.Add(temp); } } } /// <summary> /// Get the category name according to the load case category id. /// </summary> private string GetCategoryName(Autodesk.Revit.DB.ElementId loadCaseCategoryId, List<Category> loadCaseCategories) { string categoryName = ""; foreach (Category category in loadCaseCategories) { if (category.Id.Equals(loadCaseCategoryId)) { categoryName = category.Name; break; } } return categoryName; }

Private Sub LoadCaseInfomation(document As Document, loadCase As LoadCase) Dim loadCaseNumber As String 'Store the load cases number Dim information As New StringBuilder(10) ' first get all the load case categories in a list Dim loadCaseCategories As New List(Of Category)() GetLoadCaseCategories(document, loadCaseCategories) 'get the load case name information.Append(vbLf & "Case Name: " & Convert.ToString(loadCase.Name)) 'get the number of the load case Dim caseNumber As Parameter = loadCase.Parameter(BuiltInParameter.LOAD_CASE_NUMBER) If caseNumber Is Nothing Then loadCaseNumber = "" Else loadCaseNumber = caseNumber.AsInteger().ToString() End If information.Append(vbLf & "Case Number: " & loadCaseNumber) 'get the category of the load case Dim caseCategoryid As Parameter = loadCase.Parameter(BuiltInParameter.LOAD_CASE_CATEGORY) Dim loadCaseCategoryId As Autodesk.Revit.DB.ElementId = caseCategoryid.AsElementId() information.Append(vbLf & "Category: " & GetCategoryName(loadCaseCategoryId, loadCaseCategories)) 'get the nature of load case Dim caseNatureId As Parameter = loadCase.Parameter(BuiltInParameter.LOAD_CASE_NATURE) Dim loadCaseNatureId As Autodesk.Revit.DB.ElementId = caseNatureId.AsElementId() Dim loadNature As LoadNature = TryCast(document.GetElement(loadCaseNatureId), LoadNature) information.Append(vbLf & "Nature: " + loadNature.Name & vbLf) 'show the information to the user TaskDialog.Show("Revit", information.ToString()) End Sub Private Sub GetLoadCaseCategories(document As Document, ByRef loadCaseCategories As List(Of Category)) 'get all the categories of load cases Dim categories As Categories = document.Settings.Categories Dim caseCategory As Category = categories.Item(BuiltInCategory.OST_LoadCases) Dim categoryNameMap As CategoryNameMap = caseCategory.SubCategories Dim iter As System.Collections.IEnumerator = categoryNameMap.GetEnumerator() iter.Reset() While iter.MoveNext() Dim temp As Category = TryCast(iter.Current, Category) If temp IsNot Nothing Then loadCaseCategories.Add(temp) End If End While End Sub ' <summary> ' Get the category name according to the load case category id. ' </summary> Private Function GetCategoryName(loadCaseCategoryId As Autodesk.Revit.DB.ElementId, loadCaseCategories As List(Of Category)) As String Dim categoryName As String = "" For Each category As Category In loadCaseCategories If category.Id.Equals(loadCaseCategoryId) Then categoryName = category.Name Exit For End If Next Return categoryName End Function