<?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: How to change wall material. in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-change-wall-material/m-p/9899044#M30290</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;As these walls are "Model-In-Place" elements (not created by Wall system families) you could write something like this (macro c#)&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public void ChangeWallStructuralMaterial()
{
    Document doc = this.ActiveUIDocument.Document;

	    using (Transaction t = new Transaction(doc, "Change Wall Structural Material"))
	    {
		 t.Start();
		
		 List&amp;lt;FamilyInstance&amp;gt; walls = new FilteredElementCollector(doc)		 
			.OfClass(typeof(FamilyInstance))
			.OfCategory(BuiltInCategory.OST_Walls)		 	
		    .Cast&amp;lt;FamilyInstance&amp;gt;()
			.ToList();
		 
   		 Material mat = new FilteredElementCollector(doc)
	        .OfClass(typeof(Material))
	        .Cast&amp;lt;Material&amp;gt;()
	        .FirstOrDefault(q =&amp;gt; q.Name == "Precast Wall Status 1 (DS)") as Material; 
		   	
        foreach (Element wall in walls)
        {			        	
        	ElementId elemTypeId = wall.GetTypeId();
			ElementType elemType = (ElementType)doc.GetElement(elemTypeId);
            elemType.LookupParameter("Structural Material").Set(mat.Id);
        }
        
    	t.Commit();
	   }						
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wall_model-in-place.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/849286i39208A5BA78F6DDB/image-size/large?v=v2&amp;amp;px=999" role="button" title="wall_model-in-place.png" alt="wall_model-in-place.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Nov 2020 10:26:03 GMT</pubDate>
    <dc:creator>so-chong</dc:creator>
    <dc:date>2020-11-27T10:26:03Z</dc:date>
    <item>
      <title>How to change wall material.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-change-wall-material/m-p/9886530#M30288</link>
      <description>&lt;P&gt;I want to change all wall material is "Precast Wall Status 1 (DS)".&lt;/P&gt;&lt;P&gt;-------------------------------------&lt;/P&gt;&lt;P&gt;FilteredElementCollector assCollector = new FilteredElementCollector(doc).OfClass(typeof(AssemblyInstance));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; foreach(Element el in assCollector){&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ElementFilter EF = new ElementClassFilter(typeof(FamilyInstance));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; IList&amp;lt;ElementId&amp;gt; dependentElementIDS = el.GetDependentElements(EF) as IList&amp;lt;ElementId&amp;gt;;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; foreach(ElementId dependentElementID in dependentElementIDS){&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Element elem = doc.GetElement(dependentElementID);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (elem.Name == "type-aw"){&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ElementType elemType = doc.GetElement(elem.GetTypeId()) as ElementType;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; elemType.LookupParameter("Structural Material").SetValueString("Precast Wall Status 1 (DS)");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } // if&lt;BR /&gt;&amp;nbsp; &amp;nbsp; } //foreach&lt;BR /&gt;}/foreach&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------------------------------------&lt;BR /&gt;Thank you.&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="22-11-2563 11-50-22.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/847157iA026071A6154CD75/image-size/large?v=v2&amp;amp;px=999" role="button" title="22-11-2563 11-50-22.png" alt="22-11-2563 11-50-22.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2020 04:59:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-change-wall-material/m-p/9886530#M30288</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-22T04:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to change wall material.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-change-wall-material/m-p/9886716#M30289</link>
      <description>&lt;P&gt;I have writen a program about changing wall material in python, and the code may be helpful for you.&lt;/P&gt;&lt;P&gt;The funciton used can be found in Revit API docs.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;change_wall_material&lt;/SPAN&gt;(&lt;SPAN&gt;self&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;wall&lt;SPAN&gt;, &lt;/SPAN&gt;m_Id):# m_Id means the Id of Target material&lt;BR /&gt;    &lt;SPAN&gt;if &lt;/SPAN&gt;wall.GetType().ToString() == &lt;SPAN&gt;'Autodesk.Revit.DB.Wall'&lt;/SPAN&gt;:&lt;BR /&gt;        wall = wall.WallType&lt;BR /&gt;    marks = wall.GetCompoundStructure()&lt;BR /&gt;    &lt;SPAN&gt;if &lt;/SPAN&gt;marks:&lt;BR /&gt;        marks.SetMaterialId(&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;ElementId(m_Id))#Change the material of first layer of wall&lt;BR /&gt;        wall.SetCompoundStructure(marks)&lt;BR /&gt;        I = wall.GetCompoundStructure()&lt;BR /&gt;        print(I.GetLayers()[&lt;SPAN&gt;0&lt;/SPAN&gt;].MaterialId)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2020 09:17:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-change-wall-material/m-p/9886716#M30289</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-22T09:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to change wall material.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-change-wall-material/m-p/9899044#M30290</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;As these walls are "Model-In-Place" elements (not created by Wall system families) you could write something like this (macro c#)&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public void ChangeWallStructuralMaterial()
{
    Document doc = this.ActiveUIDocument.Document;

	    using (Transaction t = new Transaction(doc, "Change Wall Structural Material"))
	    {
		 t.Start();
		
		 List&amp;lt;FamilyInstance&amp;gt; walls = new FilteredElementCollector(doc)		 
			.OfClass(typeof(FamilyInstance))
			.OfCategory(BuiltInCategory.OST_Walls)		 	
		    .Cast&amp;lt;FamilyInstance&amp;gt;()
			.ToList();
		 
   		 Material mat = new FilteredElementCollector(doc)
	        .OfClass(typeof(Material))
	        .Cast&amp;lt;Material&amp;gt;()
	        .FirstOrDefault(q =&amp;gt; q.Name == "Precast Wall Status 1 (DS)") as Material; 
		   	
        foreach (Element wall in walls)
        {			        	
        	ElementId elemTypeId = wall.GetTypeId();
			ElementType elemType = (ElementType)doc.GetElement(elemTypeId);
            elemType.LookupParameter("Structural Material").Set(mat.Id);
        }
        
    	t.Commit();
	   }						
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wall_model-in-place.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/849286i39208A5BA78F6DDB/image-size/large?v=v2&amp;amp;px=999" role="button" title="wall_model-in-place.png" alt="wall_model-in-place.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 10:26:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-change-wall-material/m-p/9899044#M30290</guid>
      <dc:creator>so-chong</dc:creator>
      <dc:date>2020-11-27T10:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to change wall material.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-change-wall-material/m-p/9900373#M30291</link>
      <description>&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Nov 2020 01:29:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-change-wall-material/m-p/9900373#M30291</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-28T01:29:04Z</dc:date>
    </item>
  </channel>
</rss>

