The Revit API provides classes representing area and path reinforcement in Revit Structure.
Find the AreaReinforcementCurves for AreaReinforcement by calling the GetBoundaryCurveIds() method which returns an IList of ElementIds that represent AreaReinforcementCurves.
While the AreaReinforcement.GetBoundaryCurveIds() method returns a set of ElementIds representing AreaReinforcementCurves, which have a property that returns a Curve, the PathReinforcement.GetCurveElementIds() method returns a collection of ElementIds that represent ModelCurves. There is no way to flip the PathReinforcement except by on creation using the PathReinforcement.Create() method. PathReinforcment can only be created using an array of curves.
Figure 155: PathReinforcement ModelCurves in edit mode
For more details about retrieving an Element's Geometry, refer to Geometry.
The overloaded AreaReinforcement.Create() method provides two ways to create new AreaReinforcement: based on a host boundary or from an array of curves. The Major Direction of the area reinforcement can be set when creating a new AreaReinforcement using either of the overloaded Create() methods, but the AreaReinforcment.Direction property is read-only.
Code Region 29-3: Creating area reinforcement |
AreaReinforcement CreateAreaReinforcementInWall(Wall wall, Autodesk.Revit.DB.Document document) { // Get the wall analytical profile whose curves will define the boundary of the the area reinforcement AnalyticalModel analytical = wall.GetAnalyticalModel() as AnalyticalModel; if (null == analytical) { throw new Exception("Can't get AnalyticalModel from the selected wall"); } IList<Curve> curves = analytical.GetCurves(AnalyticalCurveType.ActiveCurves); //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; } |
Code Region 29-4: Creating path reinforcement |
PathReinforcement CreatePathReinforcement(Autodesk.Revit.DB.Document document, Wall wall) { // Create a geometry line in the selected wall as the path List<Curve> curves = new List<Curve>(); LocationCurve location = wall.Location as LocationCurve; XYZ start = location.Curve.GetEndPoint(0); XYZ end = location.Curve.GetEndPoint(1); curves.Add(Line.CreateBound(start, end)); // Obtain the default types ElementId defaultRebarBarTypeId = document.GetDefaultElementTypeId(ElementTypeGroup.RebarBarType); ElementId defaultPathReinforcementTypeId = document.GetDefaultElementTypeId(ElementTypeGroup.PathReinforcementType); ElementId defaultHookTypeId = ElementId.InvalidElementId; // Begin to create the path reinforcement PathReinforcement rein = PathReinforcement.Create(document, wall, curves, true, defaultPathReinforcementTypeId, defaultRebarBarTypeId, defaultHookTypeId, defaultHookTypeId); if (null == rein) { throw new Exception("Create path reinforcement failed."); } // Give the user some information TaskDialog.Show("Revit","Create path reinforcement succeed."); return rein; } |
When specifying the rebar shape id for a new PathReinforcement, if there are no rebar shapes in the project or you are not initially concerned with the rebar shape, you can use the static PathReinforcement method GetOrCreateDefaultRebarShape() to obtain a valid rebar shape for use with PathReinforcement. If you would like to check whether an existing rebar shape is valid for use with path reinforcement, you can call the static method PathReinforcement.IsValidRebarShapeId().
New shape types may be queried, or assigned to the path reinforcement by using the PathReinforcement properties PrimaryBarShapeId and AlternatingBarShapeId. The static method IsValidRebarShapeId() can be used to determine if you have a valid shape before attempting to set the shape id on a path reinforcement object. Note that before attempting to set alternating bars, the alternating bars parameter must be enabled in the Path Reinforcement by setting PATH_REIN_ALTERNATING BuiltInParameter to true.
The orientation of the primary and alternating bars may also be queried, or set through the properties PrimaryBarOrientation and AlternatingBarOrientation which take a value from the ReinforcementBarOrientation enumeration. You may check whether an orientation is valid for a particular path reinforcement object by calling the class method IsValidPrimaryBarOrientation() or IsValidAlternatingBarOrientation().
You may query the state of the alternating layer by calling the IsAlternatingLayerEnabled() method. The alternating layer is controlled via the built in parameter PATH_REIN_ALTERNATING on the path reinforcing element.