public void testRebar_FromShapeAndCurve_Bot() { UIDocument uiDoc = this.ActiveUIDocument; Document doc = uiDoc.Document; List <int> myListIdCategoryRebar = new List <int>(); myListIdCategoryRebar.Add((int)BuiltInCategory.OST_StructuralFraming); // Select first Element (ex beam) Reference myRefBeam = uiDoc.Selection.PickObject(ObjectType.Element, new FilterByIdCategory(myListIdCategoryRebar), "Pick a Beam..."); //Get element1 from ref Element myBeam = doc.GetElement(myRefBeam); setBeJoined(myBeam); // doc.Regenerate(); LocationCurve myLocBeam = myBeam.Location as LocationCurve; List <XYZ> myEndPoints = getPointCenterBottomLine(myBeam); XYZ p1 = myEndPoints[0]; XYZ p2 = myEndPoints[1]; XYZ Vp1p2 = p2 - p1; double p1p2Length = Vp1p2.GetLength(); // Cover bar thickness = 25 double coverBar = 25 / 304.8; XYZ p1_Rb = p1 + coverBar / p1p2Length * Vp1p2; XYZ p2_Rb = p1 + (1 - coverBar / p1p2Length) * Vp1p2; p1_Rb = new XYZ(p1_Rb.X, p1_Rb.Y, p1_Rb.Z + coverBar); p2_Rb = new XYZ(p2_Rb.X, p2_Rb.Y, p2_Rb.Z + coverBar); Line curveOfRebar = Line.CreateBound(p1_Rb, p2_Rb); List <Curve> myShape = new List <Curve>() { curveOfRebar }; Line centerLineBeam = Line.CreateBound(p1, p2); XYZ p = centerLineBeam.GetEndPoint(0); XYZ q = centerLineBeam.GetEndPoint(1); XYZ v = p - q; XYZ v1 = new XYZ(v.Y, -1 * v.X, v.Z); // RebarShape FilteredElementCollector fec3 = new FilteredElementCollector(doc) .OfClass(typeof(RebarShape)); IEnumerable <RebarShape> iterRebarBarShapes = fec3.Cast <RebarShape>(); RebarShape myRebarShape = iterRebarBarShapes.First(); // Rebartype FilteredElementCollector fec1 = new FilteredElementCollector(doc) .OfClass(typeof(RebarBarType)); IEnumerable <RebarBarType> iterRebarBarTypes = fec1.Cast <RebarBarType>(); RebarBarType myRebarType = iterRebarBarTypes.First(); // Hooktype FilteredElementCollector fec2 = new FilteredElementCollector(doc) .OfClass(typeof(RebarHookType)); IEnumerable <RebarHookType> iterRebarHookTypes = fec2.Cast <RebarHookType>(); RebarHookType myRebarHookType = iterRebarHookTypes.First(); using (Transaction trans = new Transaction(doc, "rebar test")) { trans.Start(); Rebar myRebar = Rebar.CreateFromCurvesAndShape(doc, myRebarShape, myRebarType, null, null, myBeam, v1, myShape, RebarHookOrientation.Left, RebarHookOrientation.Left); //myRebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(4,1,true, true, true); trans.Commit(); } }