<?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 Renaming Walls Names in Revit in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/renaming-walls-names-in-revit/m-p/12409340#M8350</link>
    <description>&lt;P&gt;Hello everyone, I am a Civil Engineer who just started to learn programming and RevitAPI&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I may be still a bit confused about Revit&amp;nbsp;hierarchy system of Elements (Would be nice if a someone refers me a good resource to understand it)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've made a similar plugin for Columns and it worked [Check Photo], but when I tried to do so with Walls I get errors [Check Photo of Error]&lt;BR /&gt;&lt;BR /&gt;I wrote down my code&amp;nbsp;&lt;BR /&gt;NOTE: All Application and Document is pre-defined and References attached&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I tried to debug the process the Exception appears to be in line: 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; TransactionGroup caseWall = new TransactionGroup(doc, "Renaming Wall Types");
 {
     caseWall.Start();

     FilteredElementCollector wallCollector = new FilteredElementCollector(doc);
     ElementCategoryFilter wall = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
     List&amp;lt;Element&amp;gt; listofwalls = wallCollector.OfClass(typeof(Wall)).WherePasses(wall).ToList();
     List&amp;lt;Wall&amp;gt; listofwallsWalls = new List&amp;lt;Wall&amp;gt;();

     Transaction trnWall = new Transaction(doc, "Renaming Walls");
     {

         trnWall.Start();

         foreach (Element wt in listofwalls)
         {
             
             try
             {
                 if ((wt as Wall).StructuralUsage.ToString() == "Bearing" &amp;amp;&amp;amp; (wt as WallType).Kind.ToString() == "Basic")
                 {
                     double width = (wt as Wall).Width * 0.30; //Convert to Meters
                     string actualName = wt.Name;
                     string newName;
                     newName = actualName + $"{(width)}";

                 }

                 else
                 {
                     gm.ShowTask($"WallId Failed: {(wt as Wall).Id}\n Wall Name Failed: {(wt as Wall).Name} ");
                 }

             }

             catch (Exception ex)
             {

                 gm.ShowTask(ex.Message);
             }

         }

         trnWall.Commit();

     }

     caseWall.Assimilate();
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Nov 2023 21:43:04 GMT</pubDate>
    <dc:creator>cbengaaa</dc:creator>
    <dc:date>2023-11-29T21:43:04Z</dc:date>
    <item>
      <title>Renaming Walls Names in Revit</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/renaming-walls-names-in-revit/m-p/12409340#M8350</link>
      <description>&lt;P&gt;Hello everyone, I am a Civil Engineer who just started to learn programming and RevitAPI&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I may be still a bit confused about Revit&amp;nbsp;hierarchy system of Elements (Would be nice if a someone refers me a good resource to understand it)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've made a similar plugin for Columns and it worked [Check Photo], but when I tried to do so with Walls I get errors [Check Photo of Error]&lt;BR /&gt;&lt;BR /&gt;I wrote down my code&amp;nbsp;&lt;BR /&gt;NOTE: All Application and Document is pre-defined and References attached&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I tried to debug the process the Exception appears to be in line: 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; TransactionGroup caseWall = new TransactionGroup(doc, "Renaming Wall Types");
 {
     caseWall.Start();

     FilteredElementCollector wallCollector = new FilteredElementCollector(doc);
     ElementCategoryFilter wall = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
     List&amp;lt;Element&amp;gt; listofwalls = wallCollector.OfClass(typeof(Wall)).WherePasses(wall).ToList();
     List&amp;lt;Wall&amp;gt; listofwallsWalls = new List&amp;lt;Wall&amp;gt;();

     Transaction trnWall = new Transaction(doc, "Renaming Walls");
     {

         trnWall.Start();

         foreach (Element wt in listofwalls)
         {
             
             try
             {
                 if ((wt as Wall).StructuralUsage.ToString() == "Bearing" &amp;amp;&amp;amp; (wt as WallType).Kind.ToString() == "Basic")
                 {
                     double width = (wt as Wall).Width * 0.30; //Convert to Meters
                     string actualName = wt.Name;
                     string newName;
                     newName = actualName + $"{(width)}";

                 }

                 else
                 {
                     gm.ShowTask($"WallId Failed: {(wt as Wall).Id}\n Wall Name Failed: {(wt as Wall).Name} ");
                 }

             }

             catch (Exception ex)
             {

                 gm.ShowTask(ex.Message);
             }

         }

         trnWall.Commit();

     }

     caseWall.Assimilate();
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 21:43:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/renaming-walls-names-in-revit/m-p/12409340#M8350</guid>
      <dc:creator>cbengaaa</dc:creator>
      <dc:date>2023-11-29T21:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming Walls Names in Revit</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/renaming-walls-names-in-revit/m-p/12409976#M8351</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7010897"&gt;@cbengaaa&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; To rename the wall you have choose the &lt;A href="https://www.revitapidocs.com/2021.1/1198805b-fdbf-54bf-64d3-90dbd01b4c5f.htm" target="_blank" rel="noopener"&gt;WallType.Name&lt;/A&gt;, I have modified your code to achieve the functionality. Kindly refer the below code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Reference Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; TransactionGroup caseWall = new TransactionGroup(doc, "Renaming Wall Types");
            {
                caseWall.Start();

                FilteredElementCollector wallCollector = new FilteredElementCollector(doc);
                ElementCategoryFilter wall = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
                List&amp;lt;Element&amp;gt; listofwalls = wallCollector.OfClass(typeof(Wall)).WherePasses(wall).ToList();
                List&amp;lt;Wall&amp;gt; listofwallsWalls = new List&amp;lt;Wall&amp;gt;();

                Transaction trnWall = new Transaction(doc, "Renaming Walls");
                {

                    trnWall.Start();

                    foreach (Element wt in listofwalls)
                    {
                        Wall _wall = wt as Wall; //Converting Element to Wall

                        try
                        {
                            if (_wall.StructuralUsage==StructuralWallUsage.Bearing &amp;amp;&amp;amp; _wall.WallType.Kind == WallKind.Basic) //Using Enum for Checking dont't convert to string
                            {
                                double width = _wall.Width / 3.2808399; //Convert to Meters (To Convert feet to meter need to divide 3.2808399)
                                string actualName = wt.Name;
                                string newName;
                                newName = actualName + $"({width})"; //Brackets should be outside the curlybraces

                                //Set New Name to Wall Type
                                _wall.WallType.Name = newName;
                            }

                            else
                            {
                                gm.ShowTask($"WallId Failed: {(wt as Wall).Id}\n Wall Name Failed: {(wt as Wall).Name} ");
                            }

                        }

                        catch (Exception ex)
                        {

                            gm.ShowTask(ex.Message);
                        }

                    }

                    trnWall.Commit();

                }

                caseWall.Assimilate();
            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Reference Image:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mohamed_Arshad_0-1701319937514.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1299023iF29F7FEEEFFCE800/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Mohamed_Arshad_0-1701319937514.png" alt="Mohamed_Arshad_0-1701319937514.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note : Use &lt;A href="https://learn.microsoft.com/en-us/dotnet/api/system.math.round?view=net-8.0" target="_blank" rel="noopener"&gt;Math.Round&lt;/A&gt; to control the precision.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Links to Learn Revit API&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A href="https://spiderinnet.typepad.com/" target="_blank" rel="noopener"&gt;https://spiderinnet.typepad.com/&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A href="https://thebuildingcoder.typepad.com/" target="_blank" rel="noopener"&gt;https://thebuildingcoder.typepad.com/&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A href="https://www.autodesk.com/autodesk-university/class/Revit-Programming-Beginners-Easily-Access-Revit-API-Using-Free-Tools-2018" target="_blank" rel="noopener"&gt;https://www.autodesk.com/autodesk-university/class/Revit-Programming-Beginners-Easily-Access-Revit-API-Using-Free-Tools-2018&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A href="https://www.autodesk.com/support/technical/article/caas/tsarticles/ts/7I2bC1zUr4VjJ3U31uM66K.html" target="_blank" rel="noopener"&gt;https://www.autodesk.com/support/technical/article/caas/tsarticles/ts/7I2bC1zUr4VjJ3U31uM66K.html&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Video Tutorials&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://youtube.com/playlist?list=PLlyMZ5IcKcci1TvB4qM9S8J-RKp0DhVWO&amp;amp;si=N_G9KYKvXjA3oxLP" target="_blank" rel="noopener"&gt;https://youtube.com/playlist?list=PLlyMZ5IcKcci1TvB4qM9S8J-RKp0DhVWO&amp;amp;si=N_G9KYKvXjA3oxLP&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this will helps &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 04:58:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/renaming-walls-names-in-revit/m-p/12409976#M8351</guid>
      <dc:creator>Mohamed_Arshad</dc:creator>
      <dc:date>2023-11-30T04:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming Walls Names in Revit</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/renaming-walls-names-in-revit/m-p/12411362#M8352</link>
      <description>&lt;P&gt;&lt;EM&gt;thank you so much, you are the best!&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I guess I still need a little dive into Revit API to get it correctly.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 17:16:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/renaming-walls-names-in-revit/m-p/12411362#M8352</guid>
      <dc:creator>cbengaaa</dc:creator>
      <dc:date>2023-11-30T17:16:21Z</dc:date>
    </item>
  </channel>
</rss>

