Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create or modify a rendering asset?

4 REPLIES 4
Reply
Message 1 of 5
boostyourbim
1922 Views, 4 Replies

Create or modify a rendering asset?

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

4 REPLIES 4
Message 2 of 5

Any solution Harry??? Looks like resounding silence.



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

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.
Message 4 of 5
MD_HSETU
in reply to: boostyourbim

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

Message 5 of 5
conoves
in reply to: MD_HSETU

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community