Creates a new AreaReinforcement object from an array of curves.
This method replaces the NewAreaReinforcement method, which has been deprecated.
Namespace: Autodesk.Revit.DB.StructureAssembly: RevitAPI (in RevitAPI.dll) Version: 23.0.0.0 (23.1.0.0)
Since:
2015
Syntax
Return Value
The newly created AreaReinforcement.
Examples
CopyC#
AreaReinforcement CreateAreaReinforcementInWall(Wall wall, Autodesk.Revit.DB.Document document)
{
AnalyticalToPhysicalAssociationManager assocManager = AnalyticalToPhysicalAssociationManager.GetAnalyticalToPhysicalAssociationManager(document);
AnalyticalPanel panel = null;
if (assocManager != null)
{
ElementId associatedElementId = assocManager.GetAssociatedElementId(wall.Id);
if (associatedElementId != ElementId.InvalidElementId)
{
Element associatedElem = document.GetElement(associatedElementId);
if (associatedElem != null && associatedElem is AnalyticalPanel)
{
panel = associatedElem as AnalyticalPanel;
}
}
}
if (null == panel)
{
throw new Exception("Can't get AnalyticalModel from the selected wall");
}
IList<Curve> curves = panel.GetOuterContour().ToList();
Line firstLine = (Line)(curves[0]);
XYZ majorDirection = new XYZ(
firstLine.GetEndPoint(1).X - firstLine.GetEndPoint(0).X,
firstLine.GetEndPoint(1).Y - firstLine.GetEndPoint(0).Y,
firstLine.GetEndPoint(1).Z - firstLine.GetEndPoint(0).Z);
ElementId defaultRebarBarTypeId = document.GetDefaultElementTypeId(ElementTypeGroup.RebarBarType);
ElementId defaultAreaReinforcementTypeId = document.GetDefaultElementTypeId(ElementTypeGroup.AreaReinforcementType);
ElementId defaultHookTypeId = ElementId.InvalidElementId;
AreaReinforcement rein = AreaReinforcement.Create(document, wall, curves, majorDirection, defaultAreaReinforcementTypeId, defaultRebarBarTypeId, defaultHookTypeId);
return rein;
}
CopyVB.NET
Private Function CreateAreaReinforcementInWall(wall As Wall, document As Autodesk.Revit.DB.Document) As AreaReinforcement
Dim analytical As Autodesk.Revit.DB.Structure.AnalyticalPanel = Nothing
Dim relManager As Autodesk.Revit.DB.Structure.AnalyticalToPhysicalAssociationManager = Autodesk.Revit.DB.Structure.AnalyticalToPhysicalAssociationManager.GetAnalyticalToPhysicalAssociationManager(document)
If (relManager Is Nothing) Then
Throw New Exception("Can't get AnalyticalModel from the selected wall")
End If
Dim counterpartId As ElementId = relManager.GetAssociatedElementId(wall.Id)
If (counterpartId Is Nothing) Then
Throw New Exception("Can't get AnalyticalModel from the selected wall")
End If
analytical = document.GetElement(counterpartId)
If analytical Is Nothing Then
Throw New Exception("Can't get AnalyticalModel from the selected wall")
End If
Dim curves As IList(Of Curve) = analytical.GetOuterContour().ToList()
Dim firstLine As Line = DirectCast(curves(0), Line)
Dim majorDirection As New XYZ(firstLine.GetEndPoint(1).X - firstLine.GetEndPoint(0).X, firstLine.GetEndPoint(1).Y - firstLine.GetEndPoint(0).Y, firstLine.GetEndPoint(1).Z - firstLine.GetEndPoint(0).Z)
Dim defaultRebarBarTypeId As ElementId = document.GetDefaultElementTypeId(ElementTypeGroup.RebarBarType)
Dim defaultAreaReinforcementTypeId As ElementId = document.GetDefaultElementTypeId(ElementTypeGroup.AreaReinforcementType)
Dim defaultHookTypeId As ElementId = ElementId.InvalidElementId
Dim rein As AreaReinforcement = AreaReinforcement.Create(document, wall, curves, majorDirection, defaultAreaReinforcementTypeId, defaultRebarBarTypeId,
defaultHookTypeId)
Return rein
End Function
Exceptions
See Also