LoadCombination.GetCaseAndCombinationIds
Public Class
Returns collection of the load combination case and combination IDs.
Namespace: Autodesk.Revit.DB.Structure
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public IList<ElementId> GetCaseAndCombinationIds()
Return Value
IList. ElementId.
A collection of the load combination case and combination IDs.
Remarks
Load combination components could be load cases or other load combinations. To set them with factors use [M:Autodesk.Revit.DB.Structure.LoadCombination.SetComponents(System.Collections.Generic.IList`1{Autodesk.Revit.DB.Structure.LoadComponent})] method.
Example
#region Autodesk.Revit.DB.Structure.LoadCombination.GetComponents()#region Autodesk.Revit.DB.Structure.LoadCombination.GetUsageIds()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 number case1.Name = "DL2"; if (LoadCase.IsNumberUnique(document, 3)) { case1.Number = 3; }
// Create load nature LoadNature liveNature = LoadNature.Create(document, "Dead nature"); if (liveNature == null) throw new Exception("Create new load nature failed.");
// Change nature category, ID and number for case case1.SubcategoryId = new ElementId(BuiltInCategory.OST_LoadCasesDead); 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.ToString()));}#endregion#endregion