<?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 Set Materials on CompoundStructureLayer in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8456904#M45581</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;I want to change the material on all the layers of Walls and Floors to the same material&lt;/P&gt;
&lt;P&gt;I get the MaterialId, loop through all the Layers, make a new layer with the same thicknes and function but with the new material and then set the layer to match the new layer, but... it doesn't work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do I do wrong ??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public void ChangeMaterialonLayers(CompoundStructure LC_CS, ElementId MatId)&lt;BR /&gt; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; IList&amp;lt;CompoundStructureLayer&amp;gt; cslayers = LC_CS.GetLayers();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; int LayerIndex = 0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; foreach (CompoundStructureLayer csl in cslayers)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CompoundStructureLayer TempLayer = new CompoundStructureLayer(csl.Width, csl.Function, MatId);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LC_CS.SetLayer(LayerIndex, TempLayer);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LayerIndex++;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards Anders&lt;/P&gt;</description>
    <pubDate>Mon, 10 Dec 2018 13:10:16 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-12-10T13:10:16Z</dc:date>
    <item>
      <title>Set Materials on CompoundStructureLayer</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8456904#M45581</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;I want to change the material on all the layers of Walls and Floors to the same material&lt;/P&gt;
&lt;P&gt;I get the MaterialId, loop through all the Layers, make a new layer with the same thicknes and function but with the new material and then set the layer to match the new layer, but... it doesn't work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do I do wrong ??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public void ChangeMaterialonLayers(CompoundStructure LC_CS, ElementId MatId)&lt;BR /&gt; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; IList&amp;lt;CompoundStructureLayer&amp;gt; cslayers = LC_CS.GetLayers();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; int LayerIndex = 0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; foreach (CompoundStructureLayer csl in cslayers)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CompoundStructureLayer TempLayer = new CompoundStructureLayer(csl.Width, csl.Function, MatId);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LC_CS.SetLayer(LayerIndex, TempLayer);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LayerIndex++;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards Anders&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 13:10:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8456904#M45581</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-10T13:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Set Materials on CompoundStructureLayer</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8458929#M45582</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous,&lt;/P&gt;
&lt;P&gt;After setting the Compound structure with the compound structure layers ,Set the compound structure to the wall type or floor type.&lt;/P&gt;
&lt;PRE&gt; wall.WallType.SetCompoundStructure( compound structure );&lt;/PRE&gt;
&lt;P&gt;I think the below link will help you&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2011/03/many-issues-resolved.html#1264438" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2011/03/many-issues-resolved.html#1264438&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 06:47:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8458929#M45582</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2018-12-11T06:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Set Materials on CompoundStructureLayer</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8459097#M45583</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;Thanks, that works :-), on Floors and ceilings&lt;/P&gt;
&lt;P&gt;but, on the walls I got an exception: "This operation is valid only for non-vertical compound structures...."&lt;/P&gt;
&lt;P&gt;What is different for Walls ?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 08:22:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8459097#M45583</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-11T08:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Set Materials on CompoundStructureLayer</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8459102#M45584</link>
      <description>&lt;P&gt;Have you tested to ensure that what you are trying to achieve programmatically works manually through the user interface at all?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 08:26:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8459102#M45584</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2018-12-11T08:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Set Materials on CompoundStructureLayer</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8459190#M45585</link>
      <description>&lt;P&gt;Yes &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Manually it is the same process to change materials on the layers on Floors and Walls and the same code works fine on ceilings and Floors, but not on walls. and the exception is specific about non-vertically compound, and that must be the walls, or ?? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But I don't see the differents&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Anders&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 09:30:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8459190#M45585</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-11T09:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: Set Materials on CompoundStructureLayer</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8459556#M45586</link>
      <description>&lt;P&gt;&lt;SPAN&gt;maybe it has to do with the layerId , which maybe different from the index in the array.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LayerId.JPG" style="width: 813px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/579919iEBD2F8261CA668F5/image-size/large?v=v2&amp;amp;px=999" role="button" title="LayerId.JPG" alt="LayerId.JPG" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;CompoundStructureLayer TempLayer = new CompoundStructureLayer(csl.Width, csl.Function, MatId);
LC_CS.SetLayer(csl.LayerId, TempLayer);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 12:05:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8459556#M45586</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2018-12-11T12:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: Set Materials on CompoundStructureLayer</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8459684#M45587</link>
      <description>&lt;P&gt;If I look at a Floor and a Wall via RevitLookup, the Layers have the same LayerID, starting from 0&lt;/P&gt;
&lt;P&gt;and if I change the code to only change the material on the First Layer [0], it will do it on the Floors but still not on the Walls&amp;nbsp; !!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 12:54:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8459684#M45587</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-11T12:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Set Materials on CompoundStructureLayer</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8459945#M45588</link>
      <description>&lt;P&gt;I don't know why the Exception gets thrown for walls and not for floors.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are 2 methoeds that work:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Use&amp;nbsp; SetMaterialId()
&lt;PRE&gt;foreach( CompoundStructureLayer l in structure.GetLayers())
{
	structure.SetMaterialId(l.LayerId, mat.Id);
}	
walltype.SetCompoundStructure(structure);
&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Make a List of newLayers
&lt;PRE&gt;List&amp;lt;CompoundStructureLayer&amp;gt; layers = new List&amp;lt;CompoundStructureLayer&amp;gt;();
foreach( CompoundStructureLayer l in structure.GetLayers())
{
	CompoundStructureLayer newLayer = new CompoundStructureLayer(l.Width,l.Function,mat.Id);
        layers.Add(newLayer);
}	
structure.SetLayers(layers);
walltype.SetCompoundStructure(structure);
&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 11 Dec 2018 14:28:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/set-materials-on-compoundstructurelayer/m-p/8459945#M45588</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2018-12-11T14:28:12Z</dc:date>
    </item>
  </channel>
</rss>

