# Research on the Intelligent Construction of the Rebar Project Based on BIM
## 4 The Program Calculates How the Rebar Model Is Generated
### Stirrup Rebar Generation  
Stirrup generation path: first obtain the coordinates of the four corners of the stirrup and draw the curve shape through the four corners, as shown in Figure 5.  
The coordinates of the four corners of the stirrups are calculated by obtaining the coordinates of the origin of the structural column and the thickness of the cover input by the user. For example, the coordinates of the \(X\), \(Y\), and \(Z\) directions of the bottom surface of the structural column are \(XColumn\), \(YColumn\), and \(ZColumn\), respectively; the thickness of the rebar protective layer is _RebarCover_; the diameter of the stirrup is \(StirrupDiameter\); and the width and height of the top and bottom surface of the structural column are \(b\) and \(h\), respectively. Then, the coordinates \(location_{stirx}\) and \(location_{stiry}\) in the \(X\) and \(Y\) directions of the corner point \(1\) in the upper right corner of the bottom stirrup are obtained as:  
\[location_{stirx}=XColumn+\left(\frac{b}{2}-RebarCover-\frac{StirrupDiameter}{ 2}\right) \tag{10}\]  
\[location_{stiry}=YColumn+\left(\frac{h}{2}-RebarCover-\frac{StirrupDiameter}{ 2}\right) \tag{11}\]  
Figure 5: Schematic diagram of stirrup coordinate calculations.  
Since the currently acquired origin coordinates are the coordinates of the bottom surface of the structural column, the coordinates of the corner point 1 in the \(Z\) direction, that is, the coordinates in the height direction, are the \(Z\) coordinates of the bottom surface of the structural column plus the protective layer of the bottom surface of the rebar plus half the diameter of the stirrup. The calculated coordinates \(location_{stirz}\) are:  
\[location_{stirz}=ZColumn+BottomRebarCover+\frac{StirrupDiameter}{2} \tag{12}\]  
As shown in Figure 6, the coordinates of the four corners of the stirrups on the top surface of the structural column and the coordinates of the four corners of the stirrups on the bottom of the structural column are different only in the \(Z\) direction, that is, the height direction. The \(Z\) coordinate of the stirrups on the top surface of the structural column, \(Tlocation_{stirz}\), is:  
\[Tlocation_{stirz}=ZColumn+ColumnRight-TopRebarCover-\frac{StirrupDiameter}{2} \tag{13}\]  
_ColumnHight_ is the height of the current structural column.  
The method in the Revit API to get the height of a structural column is get_Parameter(). In this way, the coordinates of the four corner points needed to generate the stirrups on the top surface of the structural column can be calculated.  
When the coordinates of all corner points of the top and bottom stirrups of the structural column are calculated, use the Line.CreateBound() method in the Revit API and pass the coordinates of two points in the parameters of the method to create a line. Pass through corner 1 and corner 2 to create the first line; pass through corner 2 and corner 3 to create the second line; pass through corner 3 and corner 4 to create the third line; pass through corner 4 and corner 1 to create a fourth line. The final result is a closed quadrilateral wireframe. Add four lines to the List<Curve> collection.  
Use the Rebar.CreateFromCurves() method for creating bars from curves in the Revit API. Enter the parameters, such as the diameter of the stirrup, the hook of the stirrup, and the direction of the bending structure entered by the user in the parentheses, and pass in the List<Curve> collection containing four lines, and then the stirrup is generated according to the quadrilateral wire frame formed by the four lines. If the four incoming lines are not connected end to end, the program will report an error and cannot generate stirrups normally.