Anuncios
Welcome to the Revit Ideas Board! Before posting, please read the helpful tips here. Thank you for your Ideas!
Comentario
Autodesk
Autodesk

You can search for the schema in RevitAPI help. Here is the list of properties for an appearance asset of Generic schema: the property that is looking for is “GenericDiffuse”: the description in the help usually maps the name in Material browser.

 

Untitled.png 

 

Now, as “GenericDiffuse” is a property that can be connected to another property, like all a texture map, he has to do the following (this is based from the code snippet we provide for new method GetSingleConnectedAsset):

 

ElementId appearanceAssetId = material.AppearanceAssetId;

 

   AppearanceAssetElement assetElem = material.Document.GetElement(appearanceAssetId) as AppearanceAssetElement;

 

   using (Transaction t = new Transaction(material.Document, "Change material bumpmap bitmap"))

   {

      t.Start();

 

      using (AppearanceAssetEditScope editScope = new AppearanceAssetEditScope(assetElem.Document))

      {

         Asset editableAsset = editScope.Start(assetElem.Id);   // returns an editable copy of the appearance asset

 

         AssetProperty genericDiffuseProperty = editableAsset.FindByName(Generic.GenericDiffuse);

 

         // Find the connected asset (with a shortcut to get the only one)

 

         Asset connectedAsset = genericDiffuseProperty.GetSingleConnectedAsset();

 

 

         if (connectedAsset != null)

         {

            // Find the target asset property

            AssetPropertyString bitmapProperty = connectedAsset.FindByName( "unifiedbitmap_Bitmap") as AssetPropertyString;

 

            if (bitmapProperty.IsValidValue(imageFilePath))

 

               bitmapProperty.Value = imageFilePath;

         }

 

 

         editScope.Commit(true);

      }

 

      t.Commit();

   }

 

 

 

I hope that helps.