Sei sulla pagina 1di 4

Rebar.

CreateFromCurves Method
Rebar Class Example See Also Send Feedback Creates a new instance of a Rebar element within the project. Namespace: Autodesk.Revit.DB.Structure Assembly: RevitAPI (in RevitAPI.dll) Version: 2014.0.0.0 Since: 2009

Syntax
C# 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 ) Visual Basic Public Shared Function CreateFromCurves ( _ doc As Document, _ style As RebarStyle, _ barType As RebarBarType, _ startHook As RebarHookType, _ endHook As RebarHookType, _ host As Element, _ norm As XYZ, _ curves As IList(Of Curve), _ startHookOrient As RebarHookOrientation, _ endHookOrient As RebarHookOrientation, _ useExistingShapeIfPossible As Boolean, _ createNewShape As Boolean _ ) As Rebar Visual C++ 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 style barType startHook Type: Autodesk.Revit.DB.Document A document. Type: Autodesk.Revit.DB.Structure.RebarStyle The usage of the bar, "standard" or "stirrup/tie". Type: Autodesk.Revit.DB.Structure.RebarBarType A RebarBarType element that defines bar diameter, bend radius and material of the rebar. Type: Autodesk.Revit.DB.Structure.RebarHookType A RebarHookType element that defines the hook for the start of the bar. If this parameter is a null reference (Nothing in Visual Basic), it means to create a rebar with no hook. Type: Autodesk.Revit.DB.Structure.RebarHookType A RebarHookType element that defines the hook for the end of the bar. If this parameter is a null reference (Nothing in Visual Basic), it means to create a rebar with no hook. Type: Autodesk.Revit.DB.Element The element to which the rebar belongs. The element must support rebar hosting; see Autodesk.Revit.DB.Structure.RebarHostData. Type: Autodesk.Revit.DB.XYZ The normal to the plane that the rebar curves lie on.

endHook

host

norm curves

Type: System.Collections.Generic.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 and hooks should not be included in the array of curves. startHookOrient Type: Autodesk.Revit.DB.Structure.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 Type: Autodesk.Revit.DB.Structure.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 Type: System.Boolean Attempts to assign a RebarShape from those existing in the document. If no shape matches, NewRebar returns or creates a new shape, according to the parameter createNewShape. 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 Type: System.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
The newly created Rebar instance, or a null reference (Nothing in Visual Basic) if the operation fails.

Examples
CopyC# 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); 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 Parameter paramLayout = rebar.get_Parameter(BuiltInParameter.REBAR_ELEM_LAYOUT_RULE); paramLayout.Set(1); // 1 = Fixed Number Parameter paramNum = rebar.get_Parameter(BuiltInParameter.REBAR_ELEM_QUANTITY_OF_BARS); paramNum.Set(10); rebar.ArrayLength = 1.5; } return rebar; } CopyVB.NET Private Function CreateRebar(ByVal document As Autodesk.Revit.DB.Document, ByVal column As FamilyInstance, ByVal barType As RebarBarType, ByVal hookType As RebarHookType) As Rebar ' Define the rebar geometry information - Line 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) ' Create the line rebar 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, hookType, hookType, column, _ origin, curves, RebarHookOrientation.Right, RebarHookOrientation.Left, True, True) If rebar__1 IsNot Nothing Then ' set specific layout for new rebar Dim paramLayout As Parameter = rebar__1.Parameter(BuiltInParameter.REBAR_ELEM_LAYOUT_RULE) paramLayout.[Set](1) ' 1 = Fixed Number Dim paramNum As Parameter = rebar__1.Parameter(BuiltInParameter.REBAR_ELEM_QUANTITY_OF_BARS) paramNum.[Set](10) rebar__1.ArrayLength = 1.5

End If Return rebar__1 End Function

Exceptions
Exception Autodesk.Revit.Exceptions.ArgumentException Condition 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. A non-optional argument was NULL norm has zero length. -or- A value passed for an enumeration argument is not a member of that enumeration Both useExistingShapeIfPossible and createNewShape are false. -orcurves contains non-fillet arcs with radii that are less than the minimum bend radius for the RebarBarType and bar style. None of the following disciplines is enabled: Structural.

Autodesk.Revit.Exceptions.ArgumentNullException Autodesk.Revit.Exceptions.ArgumentOutOfRangeException

Autodesk.Revit.Exceptions.ArgumentsInconsistentException

Autodesk.Revit.Exceptions.DisabledDisciplineException

See Also
Rebar Class Autodesk.Revit.DB.Structure Namespace

Potrebbero piacerti anche