RebarCreateFromCurves(Document, RebarStyle, RebarBarType, RebarHookType, RebarHookType, Element, XYZ, IListCurve, RebarHookOrientation, RebarHookOrientation, Boolean, Boolean) Method

Creates a new instance of a shape driven Rebar element within the project.

Namespace: Autodesk.Revit.DB.Structure
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public static Rebar CreateFromCurves(
	Document doc,
	RebarStyle style,
	RebarBarType barType,
	RebarHookType startHook,
	RebarHookType endHook,
	Element host,
	XYZ norm,
	IList<Curve> curves,
	RebarHookOrientation startHookOrient,
	RebarHookOrientation endHookOrient,
	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.
startHook  RebarHookType
A RebarHookType element that defines the hook for the start of the bar. If this parameter is , it means to create a rebar with no hook.
endHook  RebarHookType
A RebarHookType element that defines the hook for the end of the bar. If this parameter is , it means to create a rebar with no hook.
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  IListCurve
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 and hooks should not be included in the array of curves.
startHookOrient  RebarHookOrientation
Defines the orientation of the hook plane at the start of the rebar with respect to the orientation of the first curve and the plane normal. Only two values are permitted: Value = Right: The hook is on your right as you stand at the end of the bar, with the bar behind you, taking the bar's normal as "up." Value = Left: The hook is on your left as you stand at the end of the bar, with the bar behind you, taking the bar's normal as "up."
endHookOrient  RebarHookOrientation
Defines the orientation of the hook plane at the end of the rebar with respect to the orientation of the last curve and the plane normal. Only two values are permitted: Value = Right: The hook is on your right as you stand at the end of the bar, with the bar behind you, taking the bar's normal as "up." Value = Left: The hook is on your left as you stand at the end of the bar, with the bar behind you, taking the bar's normal as "up."
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". If the RebarShapeDefinesHooks flag in ReinforcementSettings has been set to false, and a RebarShape cannot be found with both matching curves and hooks, then this method will perform a second search, ignoring hook information.
createNewShape  Boolean
Creates a shape in the document to match the curves, hooks, and style specified, 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 if the operation fails.
Exceptions
ExceptionCondition
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.
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
Rebar CreateRebar(Autodesk.Revit.DB.Document document, FamilyInstance column, RebarBarType barType, RebarHookType hookType)
{
    // Define the rebar geometry information - Line rebar
    LocationPoint location = column.Location as LocationPoint;
    XYZ origin = location.Point;
    XYZ normal = new XYZ(1, 0, 0);
    // create rebar 9' long
    XYZ rebarLineEnd = new XYZ(origin.X, origin.Y, origin.Z + 9);
    Line rebarLine = Line.CreateBound(origin, rebarLineEnd);

    // Create the line rebar
    IList<Curve> curves = new List<Curve>();
    curves.Add(rebarLine);

    Rebar rebar = Rebar.CreateFromCurves(document, Autodesk.Revit.DB.Structure.RebarStyle.Standard, barType, hookType, hookType,
                        column, origin, curves, RebarHookOrientation.Right, RebarHookOrientation.Left, true, true);

    if (null != rebar)
    {
        // set specific layout for new rebar as fixed number, with 10 bars, distribution path length of 1.5'
        // with bars of the bar set on the same side of the rebar plane as indicated by normal
        // and both first and last bar in the set are shown
        rebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(10, 1.5, true, true, true);
    }

    return rebar;
}
See Also