Hello,
after some test here is an approach by selecting a face, I could not explain everything because the structure is really out of my area of expertise, and this part of the API seems really very complex to understand

import sys
import clr
import math
from System.Collections.Generic import IList, List
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Selection import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
Btm_bar_type = UnwrapElement(IN[0])
Top_bar_type = UnwrapElement(IN[1])
bar_Hook_type = UnwrapElement(IN[2])
cover = IN[3]/0.3048
spacing = 0.10/0.3048
TaskDialog.Show("Selection", "Pick a Face")
ref = uidoc.Selection.PickObject(ObjectType.Face, "Pick a Face")
# get Face Geometry
sel_elem = doc.GetElement(ref)
tf1 = sel_elem.GetTotalTransform()
face = sel_elem.GetGeometryObjectFromReference(ref)
# get the instance of Face Normal (Transformed)
faceNormal = tf1.OfVector(face.FaceNormal)
#beam_width
width = doc.GetElement(sel_elem.GetTypeId()).LookupParameter("b").AsDouble()
# get beam direction
beam_direction = sel_elem.Location.Curve.Direction
#
# create an transfrom for onternal offset
tf2 = DB.Transform.CreateTranslation(face.FaceNormal.Negate() * 0.1)
curveLoop = face.GetEdgesAsCurveLoops()[0]
# move curveloop inside the beam
# compute a transformation translation
offset_curvloop = DB.CurveLoop.CreateViaOffset(curveLoop, -0.1, face.FaceNormal)
# apply the fully transform to get the instance of Geometry
offset_curvloop = DB.CurveLoop.CreateViaTransform(offset_curvloop, tf1.Multiply(tf2))
# get top and bottom curves
curvesorted = sorted(offset_curvloop, key = lambda x : x.Length)
bottomLine, topLine = sorted(curvesorted[2:], key = lambda x : x.GetEndPoint(0))
TransactionManager.Instance.ForceCloseTransaction()
t = Transaction(doc, "Script Rebar")
t.Start()
# compute the normal for Rebar
if faceNormal.CrossProduct(beam_direction).IsAlmostEqualTo(XYZ(0,0,-1)):
normT = topLine.Direction.CrossProduct(XYZ.BasisZ)
normB = topLine.Direction.CrossProduct(XYZ.BasisZ)
else:
normT = topLine.Direction.CrossProduct(XYZ.BasisZ).Negate()
normB = topLine.Direction.CrossProduct(XYZ.BasisZ).Negate()
Top_rebar = Rebar.CreateFromCurves(doc,
RebarStyle.Standard,
Btm_bar_type,
bar_Hook_type,
bar_Hook_type,
sel_elem,
normT,
List[DB.Curve]([topLine]),
RebarHookOrientation.Left,
RebarHookOrientation.Right,
True,
True)
Top_rebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(math.ceil((width-2*cover)/spacing), width-2*cover, True, True, True)
Btm_rebar = Rebar.CreateFromCurves(doc,
RebarStyle.Standard,
Btm_bar_type,
bar_Hook_type,
bar_Hook_type,
sel_elem,
normB,
List[DB.Curve]([bottomLine]),
RebarHookOrientation.Left,
RebarHookOrientation.Right,
True,
True)
Btm_rebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(math.ceil((width-2*cover)/spacing), width-2*cover, True, True, True)
t.Commit()
t.Dispose()
OUT = sel_elem, face, bottomLine.ToProtoType(), topLine.ToProtoType()
