LoadComponent Constructor |
Constructs a new instance of a LoadComponent.
The load case or combination id.
The load case or combination factor.
Namespace: Autodesk.Revit.DB.StructureAssembly: RevitAPI (in RevitAPI.dll) Version: 27.0.4.0 (27.0.4.0)
Syntaxpublic LoadComponent(
ElementId loadCaseOrCombinationId,
double factor
)
Public Sub New (
loadCaseOrCombinationId As ElementId,
factor As Double
)
public:
LoadComponent(
ElementId^ loadCaseOrCombinationId,
double factor
)
new :
loadCaseOrCombinationId : ElementId *
factor : float -> LoadComponentParameters
- loadCaseOrCombinationId ElementId
-
- factor Double
-
Exceptions
Example#region Autodesk.Revit.DB.Structure.LoadCombination.SetComponents(System.Collections.Generic.IList{Autodesk.Revit.DB.Structure.LoadComponent})
#region Autodesk.Revit.DB.Structure.LoadCombination.SetUsageIds(System.Collections.Generic.IList{Autodesk.Revit.DB.ElementId})
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.ToString()));
return loadCombination;
}
#endregion
#endregion
See Also