<?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 Creating a rebar U-shape definition by RebarShapeDefinitionBySegments in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/creating-a-rebar-u-shape-definition-by/m-p/14166188#M85749</link>
    <description>&lt;P&gt;I am trying to create a simple u-shape definition of a rebar using the&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;RebarShapeDefinitionBySegments &lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;class, however I cannot get it to work even though I set it up exactly like Revit does when the same shape is created in the UI and then inspected. The shape has complete = true and creates it, however it cannot be opened for editing afterwards, which indicates something is wrong with either the default value of the parameters or the constraints. I am wondering what exactly I am doing wrong. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To make a u-shape, I define 3 segments with the following constraints:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0: Length, FixedDir (1,0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1: Length, FixedDir (0,1), 180degreeDefaultBend&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2: Length, FixedDir (-1,0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(To use 3 length parameters named a, b and c must exist but otherwise code should be able to be used as is )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        private static RebarShapeDefinition CreateShapeDefinitionTest_U_shape(Document document)
        {
            var definition = new RebarShapeDefinitionBySegments(document, 3);
            definition.AddParameter(document.GetParameterId("a"), 200d.FromMillimeters());
            definition.AddParameter(document.GetParameterId("b"), 200d.FromMillimeters());
            definition.AddParameter(document.GetParameterId("c"), 200d.FromMillimeters());

            var segment0 = definition.GetSegment(0);
            List&amp;lt;RebarShapeConstraint&amp;gt; segment0constraints = new List&amp;lt;RebarShapeConstraint&amp;gt;()
            {
                new RebarShapeConstraintSegmentLength(
                 document.GetParameterId("a"),
                 RebarShapeSegmentEndReferenceType.Exterior,
                 RebarShapeSegmentEndReferenceType.Exterior),

                new RebarShapeConstraintFixedSegmentDir(new UV(1,0))
            };
            segment0.SetConstraints(segment0constraints);

            var segment1 = definition.GetSegment(1);
            List&amp;lt;RebarShapeConstraint&amp;gt; segment1constraints = new List&amp;lt;RebarShapeConstraint&amp;gt;()
            {
                new RebarShapeConstraintSegmentLength(
                 document.GetParameterId("b"),
                 RebarShapeSegmentEndReferenceType.Exterior,
                 RebarShapeSegmentEndReferenceType.Exterior),

                new RebarShapeConstraint180DegreeDefaultBend(),
                new RebarShapeConstraintFixedSegmentDir(new UV(0,1)),
            };
            segment1.SetConstraints(segment1constraints);

            //Segment 2.
            var segment2 = definition.GetSegment(2);
            List&amp;lt;RebarShapeConstraint&amp;gt; segment2constraints = new List&amp;lt;RebarShapeConstraint&amp;gt;()
            {
                new RebarShapeConstraintSegmentLength(
                 document.GetParameterId("c"),
                 RebarShapeSegmentEndReferenceType.Exterior,
                 RebarShapeSegmentEndReferenceType.Exterior),

                new RebarShapeConstraintFixedSegmentDir(new UV(-1,0))

            };
            segment2.SetConstraints(segment2constraints);


            definition.AddBendDefaultRadius(0, RebarShapeVertexTurn.Default, RebarShapeBendAngle.Obtuse);
            definition.AddBendDefaultRadius(1, RebarShapeVertexTurn.Left, RebarShapeBendAngle.Right);
            definition.AddBendDefaultRadius(2, RebarShapeVertexTurn.Left, RebarShapeBendAngle.Right);
            definition.AddBendDefaultRadius(3, RebarShapeVertexTurn.Default, RebarShapeBendAngle.Obtuse);

            return definition;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and to use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        private static void CreateShapeTest(Document document, RebarShapeDefinition shapeDefinition, string shapeName)
        {
            using (Transaction transaction = new Transaction(document, "Create shape"))
            {
                transaction.Start();

                var rebarShape2 = RebarShape.Create(
                document,
                shapeDefinition,
                null,
                RebarStyle.Standard,
                StirrupTieAttachmentType.InteriorFace,
                 0,
                 new RebarShapeTerminationsData(document)
                );

                rebarShape2.Name = shapeName;

                transaction.Commit();
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jun 2026 09:48:04 GMT</pubDate>
    <dc:creator>vhh7Z3D2</dc:creator>
    <dc:date>2026-06-15T09:48:04Z</dc:date>
    <item>
      <title>Creating a rebar U-shape definition by RebarShapeDefinitionBySegments</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-a-rebar-u-shape-definition-by/m-p/14166188#M85749</link>
      <description>&lt;P&gt;I am trying to create a simple u-shape definition of a rebar using the&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;RebarShapeDefinitionBySegments &lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;class, however I cannot get it to work even though I set it up exactly like Revit does when the same shape is created in the UI and then inspected. The shape has complete = true and creates it, however it cannot be opened for editing afterwards, which indicates something is wrong with either the default value of the parameters or the constraints. I am wondering what exactly I am doing wrong. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To make a u-shape, I define 3 segments with the following constraints:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0: Length, FixedDir (1,0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1: Length, FixedDir (0,1), 180degreeDefaultBend&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2: Length, FixedDir (-1,0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(To use 3 length parameters named a, b and c must exist but otherwise code should be able to be used as is )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        private static RebarShapeDefinition CreateShapeDefinitionTest_U_shape(Document document)
        {
            var definition = new RebarShapeDefinitionBySegments(document, 3);
            definition.AddParameter(document.GetParameterId("a"), 200d.FromMillimeters());
            definition.AddParameter(document.GetParameterId("b"), 200d.FromMillimeters());
            definition.AddParameter(document.GetParameterId("c"), 200d.FromMillimeters());

            var segment0 = definition.GetSegment(0);
            List&amp;lt;RebarShapeConstraint&amp;gt; segment0constraints = new List&amp;lt;RebarShapeConstraint&amp;gt;()
            {
                new RebarShapeConstraintSegmentLength(
                 document.GetParameterId("a"),
                 RebarShapeSegmentEndReferenceType.Exterior,
                 RebarShapeSegmentEndReferenceType.Exterior),

                new RebarShapeConstraintFixedSegmentDir(new UV(1,0))
            };
            segment0.SetConstraints(segment0constraints);

            var segment1 = definition.GetSegment(1);
            List&amp;lt;RebarShapeConstraint&amp;gt; segment1constraints = new List&amp;lt;RebarShapeConstraint&amp;gt;()
            {
                new RebarShapeConstraintSegmentLength(
                 document.GetParameterId("b"),
                 RebarShapeSegmentEndReferenceType.Exterior,
                 RebarShapeSegmentEndReferenceType.Exterior),

                new RebarShapeConstraint180DegreeDefaultBend(),
                new RebarShapeConstraintFixedSegmentDir(new UV(0,1)),
            };
            segment1.SetConstraints(segment1constraints);

            //Segment 2.
            var segment2 = definition.GetSegment(2);
            List&amp;lt;RebarShapeConstraint&amp;gt; segment2constraints = new List&amp;lt;RebarShapeConstraint&amp;gt;()
            {
                new RebarShapeConstraintSegmentLength(
                 document.GetParameterId("c"),
                 RebarShapeSegmentEndReferenceType.Exterior,
                 RebarShapeSegmentEndReferenceType.Exterior),

                new RebarShapeConstraintFixedSegmentDir(new UV(-1,0))

            };
            segment2.SetConstraints(segment2constraints);


            definition.AddBendDefaultRadius(0, RebarShapeVertexTurn.Default, RebarShapeBendAngle.Obtuse);
            definition.AddBendDefaultRadius(1, RebarShapeVertexTurn.Left, RebarShapeBendAngle.Right);
            definition.AddBendDefaultRadius(2, RebarShapeVertexTurn.Left, RebarShapeBendAngle.Right);
            definition.AddBendDefaultRadius(3, RebarShapeVertexTurn.Default, RebarShapeBendAngle.Obtuse);

            return definition;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and to use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        private static void CreateShapeTest(Document document, RebarShapeDefinition shapeDefinition, string shapeName)
        {
            using (Transaction transaction = new Transaction(document, "Create shape"))
            {
                transaction.Start();

                var rebarShape2 = RebarShape.Create(
                document,
                shapeDefinition,
                null,
                RebarStyle.Standard,
                StirrupTieAttachmentType.InteriorFace,
                 0,
                 new RebarShapeTerminationsData(document)
                );

                rebarShape2.Name = shapeName;

                transaction.Commit();
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2026 09:48:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-a-rebar-u-shape-definition-by/m-p/14166188#M85749</guid>
      <dc:creator>vhh7Z3D2</dc:creator>
      <dc:date>2026-06-15T09:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a rebar U-shape definition by RebarShapeDefinitionBySegments</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-a-rebar-u-shape-definition-by/m-p/14166910#M85755</link>
      <description>&lt;P&gt;UI, you need to fix how the segments are constrained to each other and correct the bend indices.The main issue preventing editing is that you over-constrained the directions using FixedSegmentDir on every segment instead of using relative turn constraints. Additionally, a 3-segment shape only has internal bends, so declaring 4 bend radii corrupts the shape definition structure The Corrected CodeReplace your current definition method with this clean, fully editable setup:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;private static RebarShapeDefinition CreateShapeDefinitionTest_U_shape(Document document)
{
    // 3 segments mean 3 lines and 2 internal corners (bends)
    var definition = new RebarShapeDefinitionBySegments(document, 3);
    
    definition.AddParameter(document.GetParameterId("a"), 200d.FromMillimeters());
    definition.AddParameter(document.GetParameterId("b"), 200d.FromMillimeters());
    definition.AddParameter(document.GetParameterId("c"), 200d.FromMillimeters());

    // --- Segment 0 (First Leg) ---
    var segment0 = definition.GetSegment(0);
    List&amp;lt;RebarShapeConstraint&amp;gt; segment0constraints = new List&amp;lt;RebarShapeConstraint&amp;gt;()
    {
        new RebarShapeConstraintSegmentLength(
            document.GetParameterId("a"), 
            RebarShapeSegmentEndReferenceType.Exterior, 
            RebarShapeSegmentEndReferenceType.Exterior),
        new RebarShapeConstraintFixedSegmentDir(new UV(1,0)) // Base orientation anchor
    };
    segment0.SetConstraints(segment0constraints);

    // --- Segment 1 (Base of the U) ---
    var segment1 = definition.GetSegment(1);
    List&amp;lt;RebarShapeConstraint&amp;gt; segment1constraints = new List&amp;lt;RebarShapeConstraint&amp;gt;()
    {
        new RebarShapeConstraintSegmentLength(
            document.GetParameterId("b"), 
            RebarShapeSegmentEndReferenceType.Exterior, 
            RebarShapeSegmentEndReferenceType.Exterior),
        // Tells Revit this segment turns 90 degrees left relative to segment 0
        new RebarShapeConstraintCircularity(RebarShapeVertexTurn.Left) 
    };
    segment1.SetConstraints(segment1constraints);

    // --- Segment 2 (Third Leg) ---
    var segment2 = definition.GetSegment(2);
    List&amp;lt;RebarShapeConstraint&amp;gt; segment2constraints = new List&amp;lt;RebarShapeConstraint&amp;gt;()
    {
        new RebarShapeConstraintSegmentLength(
            document.GetParameterId("c"), 
            RebarShapeSegmentEndReferenceType.Exterior, 
            RebarShapeSegmentEndReferenceType.Exterior),
        // Tells Revit this segment turns 90 degrees left relative to segment 1
        new RebarShapeConstraintCircularity(RebarShapeVertexTurn.Left)
    };
    segment2.SetConstraints(segment2constraints);

    // --- Define Bend Radii ---
    // A 3-segment shape has only 2 vertices (index 0 and 1). 
    definition.AddBendDefaultRadius(0, RebarShapeVertexTurn.Left, RebarShapeBendAngle.Right);
    definition.AddBendDefaultRadius(1, RebarShapeVertexTurn.Left, RebarShapeBendAngle.Right);

    return definition;
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;Did you find this post helpful? If it gave you one or more solutions,&lt;/P&gt;
&lt;P&gt;don't forget to click the Accept Solution button and leave a &amp;lt; like !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2" color="#999999"&gt;&lt;EM&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/19092244"&gt;@Radwan-Almsora&lt;/a&gt;&amp;nbsp;-&lt;SPAN class="TextRun SCXO10211469 BCX8" data-contrast="none"&gt;&lt;SPAN class="NormalTextRun SCXO10211469 BCX8"&gt;- this post has been edited due to&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;A class="HyperlinkV2 SCXO10211469 BCX8" href="https://forums.autodesk.com/t5/forum-user-guides/community-rules-and-etiquette/td-p/9581007" rel="noreferrer noopener" target="_blank"&gt;&lt;SPAN class="TextRun SCXO10211469 BCX8" data-contrast="auto"&gt;&lt;SPAN class="NormalTextRun SCXO10211469 BCX8"&gt;Community Rules &amp;amp; Etiquette violation&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN class="TextRun SCXO10211469 BCX8" data-contrast="none"&gt;&lt;SPAN class="NormalTextRun SCXO10211469 BCX8"&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="EOP SCXO10211469 BCX8"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2026 16:18:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-a-rebar-u-shape-definition-by/m-p/14166910#M85755</guid>
      <dc:creator>Radwan-Almsora</dc:creator>
      <dc:date>2026-06-16T16:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a rebar U-shape definition by RebarShapeDefinitionBySegments</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-a-rebar-u-shape-definition-by/m-p/14167437#M85758</link>
      <description>&lt;P&gt;This looks like an AI answer, and it is incorrect. There is no RebarShapeConstraintCircularity class. Also there is 4 vertexes in a 3 segment shape, but you don't have to specify the first and last vertex radii as they always have the same values, but you do have to specify the ones in between. A 180 degree bend is a special case where the bend is created by a constraint on the segment itself, as otherwise the lines would overlap. For every other type of angle, it is created by adding a constraint to the vertex.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2026 07:09:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-a-rebar-u-shape-definition-by/m-p/14167437#M85758</guid>
      <dc:creator>vhh7Z3D2</dc:creator>
      <dc:date>2026-06-16T07:09:22Z</dc:date>
    </item>
  </channel>
</rss>

