<?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 Re: Get Rebar Layout Rule in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/get-rebar-layout-rule/m-p/12431957#M8179</link>
    <description>&lt;P&gt;Check the layout rule parameter first on the instance i.e.&lt;/P&gt;&lt;P&gt;REBAR_ELEM_LAYOUT_RULE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is an integer and the values are defined in&lt;/P&gt;&lt;P&gt;...DB.Structure.RebarLayoutRule&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should also be able to use class property&amp;nbsp;Rebar.LayoutRule same way.&lt;/P&gt;</description>
    <pubDate>Sun, 10 Dec 2023 22:32:49 GMT</pubDate>
    <dc:creator>RPTHOMAS108</dc:creator>
    <dc:date>2023-12-10T22:32:49Z</dc:date>
    <item>
      <title>Get Rebar Layout Rule</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-rebar-layout-rule/m-p/12431938#M8178</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create an addin which will update the IFC-parameter "IfcName" for all rebars in a project. However, I'm encountering a problem whenever I have a rebar set with the "Fixed number" layout. The barSpacing parameter is generating an error, because a rebar set with fixed numbers does not have any information about spacing, so it throws an error. I can not seem to find a good way to check if the layout rule is fixed numbers (or single). The Rebar class has a property named LayoutRule, which seems to be what I'm after, but it does not show up in my IDE (Visual Studio). Seems to me the property doesn't exist at all. Any suggestions how to solve this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.UI.Selection;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Autodesk.Revit.Attributes;
using System.Windows.Forms;

namespace RevitClassLibrary.Armering
{
    [Transaction(TransactionMode.Manual)]
    public class UpdateIfcName : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document doc = uidoc.Document;

            // Get all rebars in the document
            FilteredElementCollector collector = new FilteredElementCollector(doc);
            ICollection&amp;lt;Element&amp;gt; rebars = collector.OfClass(typeof(Rebar)).ToElements();

                // Iterate through each rebar and update IfcName parameter
                foreach (Element rebar in rebars)
                {
                    // Get the required parameters
                    var barQuantity = rebar.get_Parameter(BuiltInParameter.REBAR_ELEM_QUANTITY_OF_BARS).AsInteger();
                    var barSpacing = (barQuantity &amp;gt; 1) ? rebar.get_Parameter(BuiltInParameter.REBAR_ELEM_BAR_SPACING).AsValueString().TrimEnd('m').Trim() : null;
                    var barDiameter = rebar.get_Parameter(BuiltInParameter.REBAR_BAR_DIAMETER).AsValueString().TrimEnd('m').Trim();
                    var posisjonsnummer = rebar.LookupParameter("Postnummer").AsString();
                    var cqRebarSuffix = rebar.LookupParameter("CQRebarSuffix").AsString();

                    var ifcName = barQuantity + "ø" + barDiameter + "c" + barSpacing + ", " + posisjonsnummer + ", " + cqRebarSuffix;
                    
                    // Write to the IfcName parameter
                    Parameter ifcNameParameter = rebar.LookupParameter("IfcName");
                    if (ifcNameParameter != null &amp;amp;&amp;amp; !ifcNameParameter.IsReadOnly)
                    {
                        using (Transaction transaction = new Transaction(doc, "Update IfcName"))
                        {
                            transaction.Start();
                            ifcNameParameter.Set(ifcName);
                            transaction.Commit();
                        }
                    }
                }
            return Result.Succeeded;
        
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Dec 2023 22:09:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-rebar-layout-rule/m-p/12431938#M8178</guid>
      <dc:creator>tomragnarsson</dc:creator>
      <dc:date>2023-12-10T22:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: Get Rebar Layout Rule</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-rebar-layout-rule/m-p/12431957#M8179</link>
      <description>&lt;P&gt;Check the layout rule parameter first on the instance i.e.&lt;/P&gt;&lt;P&gt;REBAR_ELEM_LAYOUT_RULE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is an integer and the values are defined in&lt;/P&gt;&lt;P&gt;...DB.Structure.RebarLayoutRule&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should also be able to use class property&amp;nbsp;Rebar.LayoutRule same way.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Dec 2023 22:32:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-rebar-layout-rule/m-p/12431957#M8179</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2023-12-10T22:32:49Z</dc:date>
    </item>
  </channel>
</rss>

