<?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: Revit modify materials - Method not found in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/revit-modify-materials-method-not-found/m-p/10062721#M28450</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1035859"&gt;@RPTHOMAS108&lt;/a&gt;&amp;nbsp;! It seems it works fine now for "Default" material!&lt;/P&gt;&lt;P&gt;However, if i try to do the same thing with a material I've just created, it gives another error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Paslet87_0-1612615309401.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/877700iFE34295D3C91394E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Paslet87_0-1612615309401.png" alt="Paslet87_0-1612615309401.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-02-06 13_40_29-Autodesk Revit 2021.1 - [materials.rvt - Sheet_ A001 - Title Sheet].png" style="width: 443px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/877698iE581945B7A5A5B17/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-02-06 13_40_29-Autodesk Revit 2021.1 - [materials.rvt - Sheet_ A001 - Title Sheet].png" alt="2021-02-06 13_40_29-Autodesk Revit 2021.1 - [materials.rvt - Sheet_ A001 - Title Sheet].png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it because I've created this material with the Material.Create method?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Paslet87_1-1612615420793.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/877701iED66BAFBB7DD49B6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Paslet87_1-1612615420793.png" alt="Paslet87_1-1612615420793.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you very much again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 06 Feb 2021 12:44:58 GMT</pubDate>
    <dc:creator>SwainStrain</dc:creator>
    <dc:date>2021-02-06T12:44:58Z</dc:date>
    <item>
      <title>Revit modify materials - Method not found</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-modify-materials-method-not-found/m-p/10062493#M28448</link>
      <description>&lt;P&gt;Hi everybody,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i'm trying to modify the appearance of the "Default" material with the AppearanceAssetEditScope class. I've created the SetDiffuseColor class:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static void SetDiffuseColor(Material material, Color color)
        {
            ElementId appearanceAssetId = material.AppearanceAssetId;

            AppearanceAssetElement assetElem = material.Document.GetElement(appearanceAssetId) as AppearanceAssetElement;

            // A transaction is necessary.  Multiple changes to the same asset can be made in one transaction if required.

            using (Transaction t = new Transaction(assetElem.Document, "Change material color"))
            {
                t.Start();

                using (AppearanceAssetEditScope editScope = new AppearanceAssetEditScope(assetElem.Document))
                {
                    Asset editableAsset = editScope.Start(assetElem.Id);   // returns an editable copy of the appearance asset

                    // unlike AppearanceAssetElement.GetRenderingAsset(), the edit scope

                    // sets up the asset for editing using the classes and utilities from

                    // MaterialsManager.  The scope can keep a mapping from asset to Protein

                    // class members that are obtained from the asset, to permit use of

                    // Protein validation.  If the Asset was not obtained from an edit scope,

                    // the setter operations for asset properties must throw.

                    // Try to change values

                    AssetPropertyDoubleArray4d genericDiffuseProperty = editableAsset["generic_diffuse"] as AssetPropertyDoubleArray4d;

                    genericDiffuseProperty.SetValueAsColor(color);  // 4 length double asset properties often represent colors.

                    // Shortcut methods should be added to work directly with Color objects

                    // for these types.

                    // Commit the entire edit scope.  If the appearance asset element is used in one or more materials, they will be

                    // updated to match any changes made.

                    editScope.Commit(true);
                }

                t.Commit();
            }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and use it in my main Command class:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication app = commandData.Application;
            UIDocument uidoc = app.ActiveUIDocument;
            Document doc = uidoc.Document;

            CreateMaterial(doc);

            //Collect Materials
            FilteredElementCollector coll2 = new FilteredElementCollector(doc).OfClass(typeof(Material));
            IList&amp;lt;Element&amp;gt; mats = coll2.ToElements() as IList&amp;lt;Element&amp;gt;;

            Material myMaterial = null;

            Color matColor = new Color(255,255,255);

            foreach (var m in mats) if (m.Name == "Default")
                {
                    myMaterial = m as Material;
                }

            SetDiffuseColor(myMaterial, matColor);


            return Result.Succeeded;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is the following :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-02-06 10_03_13-New Message - Autodesk Community.png" style="width: 431px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/877677iB0D2920DCA4CC5D6/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-02-06 10_03_13-New Message - Autodesk Community.png" alt="2021-02-06 10_03_13-New Message - Autodesk Community.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;i don't understand what am i doing wrong, any help is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 09:08:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-modify-materials-method-not-found/m-p/10062493#M28448</guid>
      <dc:creator>SwainStrain</dc:creator>
      <dc:date>2021-02-06T09:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Revit modify materials - Method not found</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-modify-materials-method-not-found/m-p/10062635#M28449</link>
      <description>&lt;P&gt;From the edit scope there is likely a class of AssetProperties. This has default 'item' property that takes an integer for the index of the Asset (not a string).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It has another property named FindByName use that as is done in the example in RevitAPI.chm for AppearanceAssetEditScope.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 11:39:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-modify-materials-method-not-found/m-p/10062635#M28449</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2021-02-06T11:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Revit modify materials - Method not found</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-modify-materials-method-not-found/m-p/10062721#M28450</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1035859"&gt;@RPTHOMAS108&lt;/a&gt;&amp;nbsp;! It seems it works fine now for "Default" material!&lt;/P&gt;&lt;P&gt;However, if i try to do the same thing with a material I've just created, it gives another error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Paslet87_0-1612615309401.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/877700iFE34295D3C91394E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Paslet87_0-1612615309401.png" alt="Paslet87_0-1612615309401.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-02-06 13_40_29-Autodesk Revit 2021.1 - [materials.rvt - Sheet_ A001 - Title Sheet].png" style="width: 443px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/877698iE581945B7A5A5B17/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-02-06 13_40_29-Autodesk Revit 2021.1 - [materials.rvt - Sheet_ A001 - Title Sheet].png" alt="2021-02-06 13_40_29-Autodesk Revit 2021.1 - [materials.rvt - Sheet_ A001 - Title Sheet].png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it because I've created this material with the Material.Create method?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Paslet87_1-1612615420793.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/877701iED66BAFBB7DD49B6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Paslet87_1-1612615420793.png" alt="Paslet87_1-1612615420793.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you very much again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 12:44:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-modify-materials-method-not-found/m-p/10062721#M28450</guid>
      <dc:creator>SwainStrain</dc:creator>
      <dc:date>2021-02-06T12:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: Revit modify materials - Method not found</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-modify-materials-method-not-found/m-p/10062859#M28451</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check if&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;material.AppearanceAssetId&lt;/LI-CODE&gt;&lt;P&gt;is a valid ElementId, I believe creating a material doesn't include the AppearanceAsset.&lt;/P&gt;&lt;P&gt;After creating the Material also add a AppearanceAsset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Revit UI adds a 'Generic' asset (Temporarily I may add!) if one is missing when opening the MaterialBrowser.&lt;/P&gt;&lt;P&gt;This will only become part of the Material after a edit is done on the material in the browser.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Michel&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 14:33:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-modify-materials-method-not-found/m-p/10062859#M28451</guid>
      <dc:creator>TripleM-Dev.net</dc:creator>
      <dc:date>2021-02-06T14:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Revit modify materials - Method not found</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-modify-materials-method-not-found/m-p/10072126#M28452</link>
      <description>&lt;P&gt;Many thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3633270"&gt;@TripleM-Dev.net&lt;/a&gt;&amp;nbsp;, this is exactly what i've done, it works&amp;nbsp; fine now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 10:44:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-modify-materials-method-not-found/m-p/10072126#M28452</guid>
      <dc:creator>SwainStrain</dc:creator>
      <dc:date>2021-02-10T10:44:37Z</dc:date>
    </item>
  </channel>
</rss>

