Create or modify a rendering asset?

Create or modify a rendering asset?

boostyourbim
Advocate Advocate
2,518 Views
4 Replies
Message 1 of 5

Create or modify a rendering asset?

boostyourbim
Advocate
Advocate

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();
    }
}

0 Likes
2,519 Views
4 Replies
Replies (4)
Message 2 of 5

Dale.Bartlett
Collaborator
Collaborator
Any solution Harry??? Looks like resounding silence.



______________
Yes, I'm Satoshi.
0 Likes
Message 3 of 5

Dale.Bartlett
Collaborator
Collaborator

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:

http://adndevblog.typepad.com/aec/2015/03/revitapi-how-to-get-asset-properties-of-material-i-want.ht...

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.  

 




______________
Yes, I'm Satoshi.
0 Likes
Message 4 of 5

Anonymous
Not applicable

Any suggestions to this? Is there still no chance to create an Asset object from the API?

0 Likes
Message 5 of 5

conoves
Autodesk
Autodesk

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.

 

 



Scott Conover

Senior Engineering Manager, Revit

0 Likes