<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Internal error when creating columns stirrup rebars in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/internal-error-when-creating-columns-stirrup-rebars/m-p/13810713#M84667</link>
    <description>&lt;P&gt;Hi All,&lt;SPAN&gt;&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/16434743"&gt;@kumara_teja&lt;/a&gt;&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4859081"&gt;@longt61&lt;/a&gt;&amp;nbsp;@naveen_kumar_t&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I’m using Dynamo inside Revit 2023 and I'm&amp;nbsp; attempting to create stirrup rebars for the columns shown in the image below. However, I received an internal error message, and I’m not sure what caused it. Could it be related to a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;RebarHookOrientation&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;issue when the column is transformed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="column_Transform.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1570857iD4C6F07AE7179254/image-size/large?v=v2&amp;amp;px=999" role="button" title="column_Transform.png" alt="column_Transform.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 459px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1570858i489F8BDEB60759B7/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As I descibed in the image below, I tick “&lt;/SPAN&gt;&lt;STRONG&gt;Include hooks in Rebar Shape definition&lt;/STRONG&gt;&lt;SPAN&gt;”,...are my settings correct?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="reinforcement.png" style="width: 781px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1571372iCD2214DE991A46D7/image-size/large?v=v2&amp;amp;px=999" role="button" title="reinforcement.png" alt="reinforcement.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Please check my attached code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import clr
import sys
import System
from System.Collections.Generic import IList, List

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import StructuralType, RebarBarType, RebarShape, RebarHookType,Rebar, RebarHookOrientation, RebarStyle, RebarCoverType

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument


# get covers parameters by face 
cover_faces = {
    "Top": BuiltInParameter.CLEAR_COVER_TOP,
    "Bottom": BuiltInParameter.CLEAR_COVER_BOTTOM,
    "Other": BuiltInParameter.CLEAR_COVER_OTHER
}

cover_types = list(FilteredElementCollector(doc).OfClass(RebarCoverType).ToElements())

# get existing covers type
def get_cover_type(distance):

    for ct in cover_types:
        if abs(ct.CoverDistance - distance) &amp;lt; 1e-6:
            return ct
    name = "Enrobage_{} cm".format(distance / 0.0328084)
    new_ct = RebarCoverType.Create(doc, name, distance)
    cover_types.append(new_ct)
    return new_ct

# set covers distance from user input
def set_column_covers(column, top, btm, side):
    # Convert cm → feet
    cover_cm = {"Top": top, "Bottom": btm, "Other": side}
    cover_ft = {face: cover_cm[face] * 0.0328084 for face in cover_cm}

    # Assign covers
    for face, bip in cover_faces.items():
        param = column.get_Parameter(bip)
        if param and param.StorageType == StorageType.ElementId:
            ct = get_cover_type(cover_ft[face])
            if ct:
                param.Set(ct.Id)

# get updated covers from user input
def get_column_covers(column):
    
    result = {}
    for face, bip in cover_faces.items():
        param = column.get_Parameter(bip)
        if param and param.StorageType == StorageType.ElementId:
            ct = doc.GetElement(param.AsElementId())
            if isinstance(ct, RebarCoverType):
                result[face] = ct.CoverDistance
    return result
    
# get solid geometry from column
def get_solid(column):
    options = Options()
    options.IncludeNonVisibleObjects = False
    options.DetailLevel = ViewDetailLevel.Fine
    geoElement = column.get_Geometry(options)
    for g in geoElement:
        if isinstance(g, GeometryInstance):
            inst_geo = g.GetInstanceGeometry()
    return next((g for g in inst_geo if isinstance(g, Solid) and g.Volume &amp;gt; 0), None)
    
# define stirrups curves for the column
def stirrup_curves(column, solid, covers):
    curves = []
    side_cover = covers.get("Other")
    btm_cover = covers.get("Bottom")
    base_face = next((f for f in solid.Faces if f.FaceNormal.IsAlmostEqualTo(XYZ.BasisZ.Negate())), None)
    norm = base_face.FaceNormal
    curveloop = base_face.GetEdgesAsCurveLoops()[0]
    curveloop1 = CurveLoop.CreateViaOffset(curveloop, side_cover, norm.Negate())
    trans = Transform.CreateTranslation(XYZ.BasisZ.Multiply(btm_cover))
    curveloop1 = CurveLoop.CreateViaTransform(curveloop1, trans)
    for c in curveloop1:
        curves.append(c)    
    return curves


columns = list(FilteredElementCollector(doc)\
    .OfCategory(BuiltInCategory.OST_StructuralColumns)\
    .WhereElementIsNotElementType()\
    .ToElements())

offset_curves = []

with Transaction(doc, "Set columns Covers") as t:
    t.Start()
    for c in columns:
        set_column_covers(c, 4.5, 6, 3.5)
    t.Commit()

rebar_types = (FilteredElementCollector(doc)
        .OfCategory(BuiltInCategory.OST_Rebar)
        .WhereElementIsElementType()
        .WherePasses(ElementClassFilter(RebarBarType))
        .ToElements())
        
rebar_shapes = (FilteredElementCollector(doc)
        .OfCategory(BuiltInCategory.OST_Rebar)
        .WhereElementIsElementType()
        .WherePasses(ElementClassFilter(RebarShape))
        .ToElements())

#shape_00 = next((s for s in rebar_shapes if s.Name == "00"), None)


bar_type = next((r for r in rebar_types if r.LookupParameter('Diamètre de barre').AsValueString() == "12 mm"), None)

bar_type1 = next((r for r in rebar_types if r.LookupParameter('Diamètre de barre').AsValueString() == "6 mm"), None)


hook_types = FilteredElementCollector(doc) \
    .OfCategory(BuiltInCategory.OST_Rebar) \
    .WhereElementIsElementType() \
    .WherePasses(ElementClassFilter(RebarHookType)) \
    .ToElements()

hook_90 = next((h for h in hook_types if Element.Name.GetValue(h) == "Standard - 90 deg"), None)

hook_135 = next((h for h in hook_types if Element.Name.GetValue(h) == "Standard - 135 deg"), None)



with Transaction(doc, "create stirrups") as t:
    t.Start()
    for col in columns:
        solid = get_solid(col)
        covers = get_column_covers(col)
        top_cover, btm_cover, side_cover = covers["Top"], covers["Bottom"], covers["Other"]
        curvs = stirrup_curves(col, solid, covers)
        L = col.LookupParameter('Longueur').AsDouble()
        s = 0.15 * 0.3048
        d = L - top_cover - btm_cover
        stirup_curves = List[Curve](curvs)
        rebar = Rebar.CreateFromCurves(
            doc,
            RebarStyle.StirrupTie,
            bar_type1, 
            hook_135, 
            hook_135, 
            col,          
            XYZ.BasisZ,        
            curvs,      
            RebarHookOrientation.Left,
            RebarHookOrientation.Left,
            True,
            True
            )
        rebar.GetShapeDrivenAccessor().SetLayoutAsMaximumSpacing(s, d, True, True, True)    
            
    t.Commit()

OUT = 0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please check my attached model file below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Sep 2025 13:26:33 GMT</pubDate>
    <dc:creator>REDO10</dc:creator>
    <dc:date>2025-09-16T13:26:33Z</dc:date>
    <item>
      <title>Internal error when creating columns stirrup rebars</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/internal-error-when-creating-columns-stirrup-rebars/m-p/13810713#M84667</link>
      <description>&lt;P&gt;Hi All,&lt;SPAN&gt;&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/16434743"&gt;@kumara_teja&lt;/a&gt;&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4859081"&gt;@longt61&lt;/a&gt;&amp;nbsp;@naveen_kumar_t&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I’m using Dynamo inside Revit 2023 and I'm&amp;nbsp; attempting to create stirrup rebars for the columns shown in the image below. However, I received an internal error message, and I’m not sure what caused it. Could it be related to a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;RebarHookOrientation&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;issue when the column is transformed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="column_Transform.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1570857iD4C6F07AE7179254/image-size/large?v=v2&amp;amp;px=999" role="button" title="column_Transform.png" alt="column_Transform.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 459px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1570858i489F8BDEB60759B7/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As I descibed in the image below, I tick “&lt;/SPAN&gt;&lt;STRONG&gt;Include hooks in Rebar Shape definition&lt;/STRONG&gt;&lt;SPAN&gt;”,...are my settings correct?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="reinforcement.png" style="width: 781px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1571372iCD2214DE991A46D7/image-size/large?v=v2&amp;amp;px=999" role="button" title="reinforcement.png" alt="reinforcement.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Please check my attached code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import clr
import sys
import System
from System.Collections.Generic import IList, List

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import StructuralType, RebarBarType, RebarShape, RebarHookType,Rebar, RebarHookOrientation, RebarStyle, RebarCoverType

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument


# get covers parameters by face 
cover_faces = {
    "Top": BuiltInParameter.CLEAR_COVER_TOP,
    "Bottom": BuiltInParameter.CLEAR_COVER_BOTTOM,
    "Other": BuiltInParameter.CLEAR_COVER_OTHER
}

cover_types = list(FilteredElementCollector(doc).OfClass(RebarCoverType).ToElements())

# get existing covers type
def get_cover_type(distance):

    for ct in cover_types:
        if abs(ct.CoverDistance - distance) &amp;lt; 1e-6:
            return ct
    name = "Enrobage_{} cm".format(distance / 0.0328084)
    new_ct = RebarCoverType.Create(doc, name, distance)
    cover_types.append(new_ct)
    return new_ct

# set covers distance from user input
def set_column_covers(column, top, btm, side):
    # Convert cm → feet
    cover_cm = {"Top": top, "Bottom": btm, "Other": side}
    cover_ft = {face: cover_cm[face] * 0.0328084 for face in cover_cm}

    # Assign covers
    for face, bip in cover_faces.items():
        param = column.get_Parameter(bip)
        if param and param.StorageType == StorageType.ElementId:
            ct = get_cover_type(cover_ft[face])
            if ct:
                param.Set(ct.Id)

# get updated covers from user input
def get_column_covers(column):
    
    result = {}
    for face, bip in cover_faces.items():
        param = column.get_Parameter(bip)
        if param and param.StorageType == StorageType.ElementId:
            ct = doc.GetElement(param.AsElementId())
            if isinstance(ct, RebarCoverType):
                result[face] = ct.CoverDistance
    return result
    
# get solid geometry from column
def get_solid(column):
    options = Options()
    options.IncludeNonVisibleObjects = False
    options.DetailLevel = ViewDetailLevel.Fine
    geoElement = column.get_Geometry(options)
    for g in geoElement:
        if isinstance(g, GeometryInstance):
            inst_geo = g.GetInstanceGeometry()
    return next((g for g in inst_geo if isinstance(g, Solid) and g.Volume &amp;gt; 0), None)
    
# define stirrups curves for the column
def stirrup_curves(column, solid, covers):
    curves = []
    side_cover = covers.get("Other")
    btm_cover = covers.get("Bottom")
    base_face = next((f for f in solid.Faces if f.FaceNormal.IsAlmostEqualTo(XYZ.BasisZ.Negate())), None)
    norm = base_face.FaceNormal
    curveloop = base_face.GetEdgesAsCurveLoops()[0]
    curveloop1 = CurveLoop.CreateViaOffset(curveloop, side_cover, norm.Negate())
    trans = Transform.CreateTranslation(XYZ.BasisZ.Multiply(btm_cover))
    curveloop1 = CurveLoop.CreateViaTransform(curveloop1, trans)
    for c in curveloop1:
        curves.append(c)    
    return curves


columns = list(FilteredElementCollector(doc)\
    .OfCategory(BuiltInCategory.OST_StructuralColumns)\
    .WhereElementIsNotElementType()\
    .ToElements())

offset_curves = []

with Transaction(doc, "Set columns Covers") as t:
    t.Start()
    for c in columns:
        set_column_covers(c, 4.5, 6, 3.5)
    t.Commit()

rebar_types = (FilteredElementCollector(doc)
        .OfCategory(BuiltInCategory.OST_Rebar)
        .WhereElementIsElementType()
        .WherePasses(ElementClassFilter(RebarBarType))
        .ToElements())
        
rebar_shapes = (FilteredElementCollector(doc)
        .OfCategory(BuiltInCategory.OST_Rebar)
        .WhereElementIsElementType()
        .WherePasses(ElementClassFilter(RebarShape))
        .ToElements())

#shape_00 = next((s for s in rebar_shapes if s.Name == "00"), None)


bar_type = next((r for r in rebar_types if r.LookupParameter('Diamètre de barre').AsValueString() == "12 mm"), None)

bar_type1 = next((r for r in rebar_types if r.LookupParameter('Diamètre de barre').AsValueString() == "6 mm"), None)


hook_types = FilteredElementCollector(doc) \
    .OfCategory(BuiltInCategory.OST_Rebar) \
    .WhereElementIsElementType() \
    .WherePasses(ElementClassFilter(RebarHookType)) \
    .ToElements()

hook_90 = next((h for h in hook_types if Element.Name.GetValue(h) == "Standard - 90 deg"), None)

hook_135 = next((h for h in hook_types if Element.Name.GetValue(h) == "Standard - 135 deg"), None)



with Transaction(doc, "create stirrups") as t:
    t.Start()
    for col in columns:
        solid = get_solid(col)
        covers = get_column_covers(col)
        top_cover, btm_cover, side_cover = covers["Top"], covers["Bottom"], covers["Other"]
        curvs = stirrup_curves(col, solid, covers)
        L = col.LookupParameter('Longueur').AsDouble()
        s = 0.15 * 0.3048
        d = L - top_cover - btm_cover
        stirup_curves = List[Curve](curvs)
        rebar = Rebar.CreateFromCurves(
            doc,
            RebarStyle.StirrupTie,
            bar_type1, 
            hook_135, 
            hook_135, 
            col,          
            XYZ.BasisZ,        
            curvs,      
            RebarHookOrientation.Left,
            RebarHookOrientation.Left,
            True,
            True
            )
        rebar.GetShapeDrivenAccessor().SetLayoutAsMaximumSpacing(s, d, True, True, True)    
            
    t.Commit()

OUT = 0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please check my attached model file below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Sep 2025 13:26:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/internal-error-when-creating-columns-stirrup-rebars/m-p/13810713#M84667</guid>
      <dc:creator>REDO10</dc:creator>
      <dc:date>2025-09-16T13:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Internal error when creating columns stirrup rebars</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/internal-error-when-creating-columns-stirrup-rebars/m-p/13817588#M84701</link>
      <description>&lt;P&gt;Can anyone help me please?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Sep 2025 09:02:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/internal-error-when-creating-columns-stirrup-rebars/m-p/13817588#M84701</guid>
      <dc:creator>REDO10</dc:creator>
      <dc:date>2025-09-19T09:02:49Z</dc:date>
    </item>
  </channel>
</rss>

