Hi,
AppearanceAssetElement.Create takes a rendering asset as an input. Is there any way to create or modify this rendering asset?
This code works to create a new material and new AppearanceAssetElement. But it relies on getting an existing asset with
app.get_Assets(AssetType.Appearance).Cast<Asset>().FirstOrDefault()
It is possible to modify this asset or create a new one? I want to be able to change the Description, Keywords, Color, and Finish.
Thanks
Harry
public void material()
{
Application app = this.Application;
UIApplication uiapp = new UIApplication(app);
Document doc = this.ActiveUIDocument.Document;
Asset a = app.get_Assets(AssetType.Appearance).Cast<Asset>().FirstOrDefault();
using (Transaction t = new Transaction(doc,"as"))
{
t.Start();
AppearanceAssetElement aa = AppearanceAssetElement.Create(doc, "My new appearance asset", a);
Material mat = doc.GetElement(Material.Create(doc, "My new material")) as Material;
mat.AppearanceAssetId = aa.Id;
t.Commit();
}
}
Hi Harry, I am using:
AppearanceAssetElement aa = AppearanceAssetElement.GetAppearanceAssetElementByName(doc, lstrAssetName);
to return a specific Asset to use as a template for new duplicates as per your code.
From this sample I can return all the properties:
but am at a loss as to how to set Appearance Asset values (description for example). Using this link logic I have tried this to no success:
if (ap.Name == "description")
{
prop.SetValue(ap, "Test description");
}
I would like to avoid any more time following down well-worn dead ends if there is no resolution. Thanks.
Any suggestions to this? Is there still no chance to create an Asset object from the API?
Please note - modification and creation of new appearance assets is now possible in the API as of Revit 2018.1.
http://blogs.autodesk.com/revit/2017/07/12/revit-2018-1-update-now-available/ - see the section on Visual Materials API.
Consult the updated Revit 2018.1 SDK from http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=2484975 for a sample, updated documentation and code snippets.
And consult Boris Shafiro's class from AU Las Vegas 2017 for even more details.