I am unable to create a stirrup shape. I tried rebar shape create method. The code I used as follows.
I am working in 2015. Please help.
The code -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Analysis;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.Creation;
using Autodesk.Revit.DB.Structure;
namespace ColumnSteel
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Automatic)]
public class Class1 : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
//Variable declaration
UIApplication app = commandData.Application;
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Autodesk.Revit.DB.Document document = uidoc.Document;
// To catch Exception
try
{
TaskDialog.Show("Revit", "Select column");
Reference r = uidoc.Selection.PickObject(ObjectType.Element);
ElementId e = r.ElementId;
Autodesk.Revit.DB.Element first = document.GetElement(e);
FamilyInstance familyInstance = first as FamilyInstance;
double length;
Rebar r1;
Location lp;
if (null != familyInstance && familyInstance.StructuralType == Autodesk.Revit.DB.Structure.StructuralType.Column)
{
LocationPoint location = first.Location as LocationPoint;
XYZ origin = location.Point;
bb = first.get_BoundingBox(null);
double minX = bb.Min.X;
double maxX = bb.Max.X;
length = (maxX - minX);
double minY = bb.Min.Y;
double maxY = bb.Max.Y;
double width = (maxY - minY);
double height = (bb.Max.Z - bb.Min.Z);
double minZ = bb.Min.Z;
double p1, p2, p3, p4, p5, p6;
XYZ point1 = new XYZ(minX+.177,minY+.177,minZ);
XYZ point2 = new XYZ(point1.X+length-.177-.177, point1.Y, pont1.Z)
Line lr1 = Line.CreateBound(point1,point2);
// Rebar Type
Autodesk.Revit.DB.Structure.RebarBarType rebarType= RebarBarType.Create(document);
rebarType.BarDiameter = 0.025;
rebarType.StirrupTieBendDiameter = .1;
// Create the line rebar
IList<Curve> curves1 = new List<Curve>();
curves1.Add(lr1);
RebarHookOrientation ho = RebarHookOrientation.Right;
RebarHookOrientation hi = RebarHookOrientation.Left;
r1 = Rebar.CreateFromCurves(document, Autodesk.Revit.DB.Structure.RebarStyle.StirrupTie ,rebarType ,null,null, first, new XYZ(0, -5, 0), curves1, ho, hi, true, true);
}
else
{
TaskDialog.Show("Revit", "Selected Item is not column");
}
return Result.Succeeded;
}
catch (Exception e)
{
TaskDialog.Show("Revit", e.Message + " " + e.Data);
return Result.Failed;
}
}
}
}