GetUsageIds Method


Returns collection of the load combination usage IDs.

Namespace: Autodesk.Revit.DB.Structure
Assembly: RevitAPI (in RevitAPI.dll) Version: 16.0.0.0 (16.0.0.0)
Since: 2016

Syntax

C#
public IList<ElementId> GetUsageIds()
Visual Basic
Public Function GetUsageIds As IList(Of ElementId)
Visual C++
public:
IList<ElementId^>^ GetUsageIds()

Return Value

A collection of the load combination usage IDs.

Examples

Copy C#
void ModifyLoadCombinationLoadCaseLoadUsageLoadNatureAndLoadComponent(Document document, LoadCombination loadCombination)
{
    // Change name of LoadCombination
    loadCombination.Name = "DL2 + RAIN1";

    // Get any LoadCase from combination
    // Combination can have assigned LoadCase or other (nested) LoadCombination so we need to filter out any LoadCombination
    LoadCase case1 = null;
    IList<ElementId> caseAndCombinationIds = loadCombination.GetCaseAndCombinationIds();
    foreach (ElementId id in caseAndCombinationIds)
    {
        Element element = document.GetElement(id);
        if (element is LoadCase)
        {
           case1 = (LoadCase)element;
           break;
        }
        else if (element is LoadCombination)
        {
           continue;
        }
    }

    if (case1 == null)
       throw new Exception("Can't get LoadCase.");

    // Change case name and nature category
    case1.Name = "DL2";

    // Create load nature
    LoadNature liveNature = LoadNature.Create(document, "Dead nature");
    if (liveNature == null)
       throw new Exception("Create new load nature failed.");

    // Change nature category and ID for case
    case1.NatureCategory = LoadNatureCategory.Dead;
    case1.NatureId = liveNature.Id;

    //Change factor for case1
    IList<LoadComponent> components = loadCombination.GetComponents();
    foreach (LoadComponent loadComponent in components)
    {
        if (loadComponent.LoadCaseOrCombinationId == case1.Id)
        {
            loadComponent.Factor = 3.0;
        }
    }

    loadCombination.SetComponents(components);

    // Remove one usage from combination
    IList<ElementId> usages = loadCombination.GetUsageIds();
    usages.RemoveAt(0);
    loadCombination.SetUsageIds(usages);

    // Give the user some information
    TaskDialog.Show("Revit", string.Format("Load Combination ID='{0}' modified successfully.", loadCombination.Id.IntegerValue));
}
Copy VB.NET
Private Sub ModifyLoadCombinationLoadCaseLoadUsageLoadNatureAndLoadComponent(document As Document, loadCombination As LoadCombination)

   ' Change name of LoadCombination
   loadCombination.Name = "DL2 + RAIN1"

   ' Get any LoadCase from combination
   ' Combination can have assigned LoadCase or other (nested) LoadCombination so we need to filter out any LoadCombination
   Dim case1 As LoadCase = Nothing
   Dim caseAndCombinationIds As List(Of ElementId) = loadCombination.GetCaseAndCombinationIds()
   For Each id As ElementId In caseAndCombinationIds
      Dim element As Element = document.GetElement(id)

      If TypeOf element Is LoadCase Then
         case1 = element
         Exit For
      ElseIf TypeOf element Is LoadCombination Then
         Continue For
      End If
   Next

   If case1 Is Nothing Then
      Throw New Exception("Can't get LoadCase.")
   End If

   ' Change case name and nature category
   case1.Name = "DL2"

   ' Create load nature
   Dim liveNature As LoadNature = LoadNature.Create(document, "Dead nature")
   If liveNature Is Nothing Then
      Throw New Exception("Create new load nature failed.")
   End If

   ' Change nature category and ID for case
   case1.NatureCategory = LoadNatureCategory.Dead
   case1.NatureId = liveNature.Id

   'Change factor for case1
   Dim components As List(Of LoadComponent) = loadCombination.GetComponents()
   For Each loadComponent As LoadComponent In components
      If loadComponent.LoadCaseOrCombinationId Is case1.Id Then
         loadComponent.Factor = 3.0
      End If
   Next

   loadCombination.SetComponents(components)

   ' Remove one usage from combination
   Dim usages As List(Of ElementId) = loadCombination.GetUsageIds()
   usages.RemoveAt(0)
   loadCombination.SetUsageIds(usages)

   ' Give the user some information
   TaskDialog.Show("Revit", String.Format("Load Combination ID='{0}' modIfied successfully.", loadCombination.Id.IntegerValue))
End Sub

See Also