Creates a new instance of a shape driven Rebar element within the project.
Namespace: Autodesk.Revit.DB.StructureAssembly: RevitAPI (in RevitAPI.dll) Version: 26.4.0.0 (26.4.0.0)
Syntax
C#
public static Rebar CreateFromCurves(
Document doc,
RebarStyle style,
RebarBarType barType,
Element host,
XYZ norm,
IList<Curve> curves,
BarTerminationsData barTerminationsData,
bool useExistingShapeIfPossible,
bool createNewShape
)
Parameters
- doc Document
-
A document.
- style RebarStyle
-
The usage of the bar, "standard" or "stirrup/tie".
- barType RebarBarType
-
A RebarBarType element that defines bar diameter, bend radius and material of the rebar.
- host Element
-
The element to which the rebar belongs. The element must support rebar hosting;
[!:Autodesk::Revit::DB::Structure::RebarHostData].
- norm XYZ
-
The normal to the plane that the rebar curves lie on.
- curves IList<Curve>
-
An array of curves that define the shape of the rebar curves.
They must belong to the plane defined by the normal and origin.
Bends, hooks and cranks should not be included in the array of curves.
- barTerminationsData BarTerminationsData
-
Data about the Rebar's terminations.
- useExistingShapeIfPossible Boolean
-
Attempts to assign a RebarShape from those existing in the document. If no shape matches, this function returns null if createNewShape is false or it will create a new shape if createNewShape is true.
When both parameters are "true", the behavior is the same as sketching rebar in the UI. At least one of these parameters must be "true".
- createNewShape Boolean
-
Creates a shape in the document to match the curves, terminations and specified style and assigns it to the new rebar instance.
Shape creation will not succeed unless one or more other shapes already exist in the document, and these shapes
have enough shape parameters to define a shape for these curves.
Return Value
Rebar
The newly created Rebar instance, or
null if the operation fails.
Exceptions
| Exception | Condition |
|---|
| ArgumentException |
The element host was not found in the given document.
-or-
host is not a valid rebar host.
-or-
The input curves is empty.
-or-
The input curves contains at least one curve which is not a bound Line or bound Arc
and is not supported for this operation.
-or-
curves do not form a valid CurveLoop.
-or-
The input curves contains at least one helical curve and is not supported for this operation.
-or-
The barTerminationsData was not created using the input document.
-or-
The input curves are too small to apply crank on them.
|
| ArgumentNullException |
A non-optional argument was null
|
| ArgumentOutOfRangeException |
norm has zero length.
-or-
A value passed for an enumeration argument is not a member of that enumeration
|
| ArgumentsInconsistentException |
Both useExistingShapeIfPossible and createNewShape are false.
-or-
curves contains non-fillet arcs with radii that are less than the
minimum bend radius for the RebarBarType and bar style.
|
Example
C#
Rebar CreateRebar(Autodesk.Revit.DB.Document document, FamilyInstance column, RebarBarType barType, BarTerminationsData barTerminationsData)
{
LocationPoint location = column.Location as LocationPoint;
XYZ origin = location.Point;
XYZ normal = new XYZ(1, 0, 0);
XYZ rebarLineEnd = new XYZ(origin.X, origin.Y, origin.Z + 9);
Line rebarLine = Line.CreateBound(origin, rebarLineEnd);
IList<Curve> curves = new List<Curve>();
curves.Add(rebarLine);
Rebar rebar = Rebar.CreateFromCurves(document, Autodesk.Revit.DB.Structure.RebarStyle.Standard, barType,
column, origin, curves, barTerminationsData, true, true);
if (null != rebar)
{
rebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(10, 1.5, true, true, true);
}
return rebar;
}
VB
Private Function CreateRebar(document As Autodesk.Revit.DB.Document, column As FamilyInstance, barType As RebarBarType, barTerminationsData As BarTerminationsData) As Rebar
Dim location As LocationPoint = TryCast(column.Location, LocationPoint)
Dim origin As XYZ = location.Point
Dim normal As New XYZ(1, 0, 0)
Dim rebarLineEnd As New XYZ(origin.X, origin.Y, origin.Z + 9)
Dim rebarLine As Line = Line.CreateBound(origin, rebarLineEnd)
Dim curves As IList(Of Curve) = New List(Of Curve)()
curves.Add(rebarLine)
Dim rebar__1 As Rebar = Rebar.CreateFromCurves(document, Autodesk.Revit.DB.[Structure].RebarStyle.Standard, barType, column,
origin, curves, barTerminationsData, True, True)
If rebar__1 IsNot Nothing Then
rebar__1.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(10, 1.5, True, True, True)
End If
Return rebar__1
End Function
See Also
Reference