Sets a collection of the load combination usage IDs.
Namespace: Autodesk.Revit.DB.StructureAssembly: RevitAPI (in RevitAPI.dll) Version: 21.0.0.0 (21.1.1.109)
Since:
2016
Syntax
C# |
---|
public void SetUsageIds(
IList<ElementId> usageIds
) |
Visual Basic |
---|
Public Sub SetUsageIds ( _
usageIds As IList(Of ElementId) _
) |
Visual C++ |
---|
public:
void SetUsageIds(
IList<ElementId^>^ usageIds
) |
Parameters
- usageIds
- Type: System.Collections.Generic..::..IList<(Of <(<'ElementId>)>)>
A collection of the load combination usage IDs.
Examples
CopyC#
LoadCombination CreateLoadCombinationLoadCaseLoadUsageLoadNatureAndLoadComponent(Document document)
{
LoadCombination loadCombination = LoadCombination.Create(document, "DL1 + RAIN1", LoadCombinationType.Combination, LoadCombinationState.Ultimate);
if (loadCombination == null)
throw new Exception("Create new load combination failed.");
FilteredElementCollector collector = new FilteredElementCollector(document);
ICollection<Element> collection = collector.OfClass(typeof(LoadCase)).ToElements();
LoadCase case1 = null;
foreach (Element e in collection)
{
LoadCase loadCase = e as LoadCase;
if (loadCase.Name == "DL1")
{
case1 = loadCase;
break;
}
}
collector = new FilteredElementCollector(document);
collection = collector.OfClass(typeof(LoadNature)).ToElements();
LoadNature nature1 = null;
foreach (Element e in collection)
{
LoadNature loadNature = e as LoadNature;
if (loadNature.Name == "Dead")
{
nature1 = loadNature;
break;
}
}
if (nature1 == null)
nature1 = LoadNature.Create(document, "Dead");
if (case1 == null)
case1 = LoadCase.Create(document, "DL1", nature1.Id, LoadCaseCategory.Dead);
LoadNature nature2 = LoadNature.Create(document, "Rain");
if (nature2 == null)
throw new Exception("Create new load nature failed.");
LoadCase case2 = LoadCase.Create(document, "RAIN1", nature2.Id, LoadCaseCategory.Snow);
if (case1 == null || case2 == null)
throw new Exception("Create new load case failed.");
List<LoadComponent> components = new List<LoadComponent>();
components.Add(new LoadComponent(case1.Id, 2.0));
components.Add(new LoadComponent(case2.Id, 1.5));
loadCombination.SetComponents(components);
LoadUsage usage1 = LoadUsage.Create(document, "Frequent");
LoadUsage usage2 = LoadUsage.Create(document, "Rare");
if (usage1 == null || usage2 == null)
throw new Exception("Create new load usage failed.");
loadCombination.SetUsageIds(new List<ElementId>() {usage1.Id, usage2.Id});
TaskDialog.Show("Revit", string.Format("Load Combination ID='{0}' created successfully.", loadCombination.Id.IntegerValue));
return loadCombination;
}
CopyVB.NET
Private Function CreateLoadCombinationLoadCaseLoadUsageLoadNatureAndLoadComponent(document As Document) As LoadCombination
Dim loadCombination__1 As LoadCombination = LoadCombination.Create(document, "DL1 + RAIN1", LoadCombinationType.Combination, LoadCombinationState.Ultimate)
If loadCombination__1 Is Nothing Then
Throw New Exception("Create new load combination failed.")
End If
Dim collector As New FilteredElementCollector(document)
Dim collection As ICollection(Of Element) = collector.OfClass(GetType(LoadCase)).ToElements()
Dim case1 As LoadCase = Nothing
For Each e As Element In collection
Dim loadCase__2 As LoadCase = TryCast(e, LoadCase)
If loadCase__2.Name = "DL1" Then
case1 = loadCase__2
Exit For
End If
Next
collector = New FilteredElementCollector(document)
collection = collector.OfClass(GetType(LoadNature)).ToElements()
Dim nature1 As LoadNature = Nothing
For Each e As Element In collection
Dim loadNature__3 As LoadNature = TryCast(e, LoadNature)
If loadNature__3.Name = "Dead" Then
nature1 = loadNature__3
Exit For
End If
Next
If nature1 Is Nothing Then
nature1 = LoadNature.Create(document, "Dead")
End If
If case1 Is Nothing Then
case1 = LoadCase.Create(document, "DL1", nature1.Id, LoadCaseCategory.Dead)
End If
Dim nature2 As LoadNature = LoadNature.Create(document, "Rain")
If nature2 Is Nothing Then
Throw New Exception("Create new load nature failed.")
End If
Dim case2 As LoadCase = LoadCase.Create(document, "RAIN1", nature2.Id, LoadCaseCategory.Snow)
If case1 Is Nothing OrElse case2 Is Nothing Then
Throw New Exception("Create new load case failed.")
End If
Dim components As New List(Of LoadComponent)()
components.Add(New LoadComponent(case1.Id, 2.0))
components.Add(New LoadComponent(case2.Id, 1.5))
loadCombination__1.SetComponents(components)
Dim usage1 As LoadUsage = LoadUsage.Create(document, "Frequent")
Dim usage2 As LoadUsage = LoadUsage.Create(document, "Rare")
If usage1 Is Nothing OrElse usage2 Is Nothing Then
Throw New Exception("Create new load usage failed.")
End If
loadCombination__1.SetUsageIds(New List(Of ElementId)() From {
usage1.Id,
usage2.Id
})
TaskDialog.Show("Revit", String.Format(, loadCombination__1.Id.IntegerValue))
Return loadCombination__1
End Function
Exceptions
See Also