Create Method (Document, Element, IList(Curve), XYZ, ElementId, ElementId, ElementId)


Creates a new AreaReinforcement object from an array of curves. This method replaces the NewAreaReinforcement method, which has been deprecated.

Namespace: Autodesk.Revit.DB.Structure
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Since:  2015

Syntax

C#
public static AreaReinforcement Create(
	Document document,
	Element hostElement,
	IList<Curve> curveArray,
	XYZ majorDirection,
	ElementId areaReinforcementTypeId,
	ElementId rebarBarTypeId,
	ElementId rebarHookTypeId
)
Visual Basic
Public Shared Function Create ( _
	document As Document, _
	hostElement As Element, _
	curveArray As IList(Of Curve), _
	majorDirection As XYZ, _
	areaReinforcementTypeId As ElementId, _
	rebarBarTypeId As ElementId, _
	rebarHookTypeId As ElementId _
) As AreaReinforcement
Visual C++
public:
static AreaReinforcement^ Create(
	Document^ document, 
	Element^ hostElement, 
	IList<Curve^>^ curveArray, 
	XYZ^ majorDirection, 
	ElementId^ areaReinforcementTypeId, 
	ElementId^ rebarBarTypeId, 
	ElementId^ rebarHookTypeId
)

Parameters

document
Type: Autodesk.Revit.DBDocument
The document.
hostElement
Type: Autodesk.Revit.DBElement
The element that will host the AreaReinforcement. The host can be a Structural Floor, Structural Wall, Structural Slab, or a Part created from a structural layer belonging to one of those element types.
curveArray
Type: System.Collections.GenericIListCurve
An array of curves that will define the outline of the AreaReinforcement.
majorDirection
Type: Autodesk.Revit.DBXYZ
A vector to define the major direction of the AreaReinforcement.
areaReinforcementTypeId
Type: Autodesk.Revit.DBElementId
The id of the AreaReinforcementType.
rebarBarTypeId
Type: Autodesk.Revit.DBElementId
The id of the RebarBarType.
rebarHookTypeId
Type: Autodesk.Revit.DBElementId
The id of the RebarHookType. If this parameter is InvalidElementId, it means to create a rebar with no hooks.

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;
         }
      }
   }
   // Get the wall analytical profile whose curves will define the boundary of the the area reinforcement 
   if (null == panel)
   {
      throw new Exception("Can't get AnalyticalModel from the selected wall");
   }

   IList<Curve> curves = panel.GetOuterContour().ToList();

   //define the Major Direction of AreaReinforcement,
   //we get direction of first Line on the Wall as the Major Direction
   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);

   // Obtain the default types
   ElementId defaultRebarBarTypeId = document.GetDefaultElementTypeId(ElementTypeGroup.RebarBarType);
   ElementId defaultAreaReinforcementTypeId = document.GetDefaultElementTypeId(ElementTypeGroup.AreaReinforcementType);
   ElementId defaultHookTypeId = ElementId.InvalidElementId;

   // Create the area reinforcement
   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
   ' Get the wall analytical profile whose curves will define the boundary of the the area reinforcement 
   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
      ' the profile reference can't be retrieved.
      Throw New Exception("Can't get AnalyticalModel from the selected wall")
   End If


   Dim curves As IList(Of Curve) = analytical.GetOuterContour().ToList()

   'define the Major Direction of AreaReinforcement,
   'we get direction of first Line on the Wall as the Major Direction
   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)

   ' Obtain the default types
   Dim defaultRebarBarTypeId As ElementId = document.GetDefaultElementTypeId(ElementTypeGroup.RebarBarType)
   Dim defaultAreaReinforcementTypeId As ElementId = document.GetDefaultElementTypeId(ElementTypeGroup.AreaReinforcementType)
   Dim defaultHookTypeId As ElementId = ElementId.InvalidElementId

   ' Create the area reinforcement
   Dim rein As AreaReinforcement = AreaReinforcement.Create(document, wall, curves, majorDirection, defaultAreaReinforcementTypeId, defaultRebarBarTypeId,
       defaultHookTypeId)

   Return rein
End Function

Exceptions

ExceptionCondition
Autodesk.Revit.ExceptionsArgumentException The input curveArray is empty. -or- The input curveArray contains at least one helical curve and is not supported for this operation. -or- The element hostElement was not found in the given document. -or- the host Element is not a valid host for Area Reinforcement, Path Reinforcement, Fabric Area or Fabric Sheet. -or- Curves in curveArray are not closed and continuous. -or- areaReinforcementTypeId should refer to an AreaReinforcementType element. -or- rebarBarTypeId should refer to an RebarBarType element. -or- rebarHookTypeId should be invalid or refer to an RebarHookType element.
Autodesk.Revit.ExceptionsArgumentNullException A non-optional argument was null
Autodesk.Revit.ExceptionsArgumentOutOfRangeException majorDirection has zero length.
Autodesk.Revit.ExceptionsForbiddenForDynamicUpdateException This method may not be called during dynamic update.

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →