<?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 How to modify element name in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-modify-element-name/m-p/13213368#M1719</link>
    <description>&lt;P&gt;I want to create a plugin primarily for modifying the names of elements in the current project file（contains walls, slabs, and family instances, etc）&lt;BR /&gt;The code is as follows&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Document doc = m_revit.ActiveUIDocument.Document;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FilteredElementCollector collector = new FilteredElementCollector(doc);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;collector.WhereElementIsNotElementType();&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Transaction ts = new Transaction(doc, "update");&lt;BR /&gt;ts.Start();&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;int num=0;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;foreach (Element elem in collector)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;num++;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;if (elem != null)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;string newname=elem.Name+num.ToString();&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;elem.Name = newname;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ts.Commit();&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it reports an error：&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This element does not support assignment of a user-specified name.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Please help me.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Dec 2024 08:46:46 GMT</pubDate>
    <dc:creator>846081597</dc:creator>
    <dc:date>2024-12-16T08:46:46Z</dc:date>
    <item>
      <title>How to modify element name</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-modify-element-name/m-p/13213368#M1719</link>
      <description>&lt;P&gt;I want to create a plugin primarily for modifying the names of elements in the current project file（contains walls, slabs, and family instances, etc）&lt;BR /&gt;The code is as follows&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Document doc = m_revit.ActiveUIDocument.Document;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FilteredElementCollector collector = new FilteredElementCollector(doc);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;collector.WhereElementIsNotElementType();&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Transaction ts = new Transaction(doc, "update");&lt;BR /&gt;ts.Start();&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;int num=0;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;foreach (Element elem in collector)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;num++;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;if (elem != null)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;string newname=elem.Name+num.ToString();&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;elem.Name = newname;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ts.Commit();&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it reports an error：&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This element does not support assignment of a user-specified name.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Please help me.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 08:46:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-modify-element-name/m-p/13213368#M1719</guid>
      <dc:creator>846081597</dc:creator>
      <dc:date>2024-12-16T08:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify element name</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-modify-element-name/m-p/13213618#M1720</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2350448"&gt;@846081597&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to consider several edge cases when renaming an element. For example, if you are renaming a wall, you can only rename the WallType name. To rename the WallType, you cannot directly rename the element. Instead, you need to first access the WallType and then rename it. Therefore, please check the element carefully before renaming it. Kindly refer to the code and image below for additional reference for wall.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code Snippet&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; using (Transaction setName= new Transaction(doc,"Set Name"))
 {
     setName.Start();

    WallType wallType= doc.GetElement( wall.GetTypeId()) as WallType;

     wallType.Name = "New Name";

     setName.Commit();
 }&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;Image Reference&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-1734349707700.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1446343iC676013431DD44C8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Mohamed_Arshad_0-1734349707700.png" alt="Mohamed_Arshad_0-1734349707700.png" /&gt;&lt;/span&gt;&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>Mon, 16 Dec 2024 11:52:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-modify-element-name/m-p/13213618#M1720</guid>
      <dc:creator>Mohamed_Arshad</dc:creator>
      <dc:date>2024-12-16T11:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify element name</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-modify-element-name/m-p/13214996#M1721</link>
      <description>&lt;P&gt;Thank you very much, you are a genius！！&lt;BR /&gt;My problem has been solved.&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2024 01:29:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-modify-element-name/m-p/13214996#M1721</guid>
      <dc:creator>846081597</dc:creator>
      <dc:date>2024-12-17T01:29:28Z</dc:date>
    </item>
  </channel>
</rss>

