Load |
Returns collection of the load combination usage IDs.
Namespace: Autodesk.Revit.DB.Structure
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)


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()));
}
