Message 1 of 18
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I am trying to set material texture path using following code (Revit 2018):
public void ChangeRenderingTexturePath(Material mat, Document doc, string texturePath) { AppearanceAssetElement appearanceAsset = (AppearanceAssetElement)doc.GetElement(mat.AppearanceAssetId); Asset renderingAsset = appearanceAsset.GetRenderingAsset(); int size = renderingAsset.Size; for (int assetIdx = 0; assetIdx < size; assetIdx++) { AssetProperty aProperty = renderingAsset[assetIdx]; if (aProperty.NumberOfConnectedProperties < 1) continue; Asset connectedAsset = aProperty.GetConnectedProperty(0) as Asset; if (connectedAsset.Name == "UnifiedBitmapSchema") { AssetPropertyString path = connectedAsset.FindByName(UnifiedBitmap.UnifiedbitmapBitmap) as AssetPropertyString; using (AppearanceAssetEditScope editScope = new AppearanceAssetEditScope(doc)) { Asset editableAsset = editScope.Start(mat.AppearanceAssetId);
// Exception thrown, asset is read only, need to use editScope path.Value = texturePath; editScope.Commit(true); } } }
I know that editScope accepts only ElementId (specifically AppearanceElementAsset.Id), but with this I can not get to edit the texture path that is saved in RenderingAsset of the AppearanceAsset.
Do anyone know any way to get around this?
Finally we can create materials with API but without textures? Does not make sense.
Thanks.
Hitting Accepted Answer is a Community Contribution from me as well as from you.
======================================================================
Solved! Go to Solution.