Xrev API Tools: Increase Productivity!

Feeds

Loading...

Tuesday, January 20, 2015

Revit Material API Workarounds

If you've worked with the Revit API you'll know that often there are holes...  That is, things you can "almost" do, but there will be one item you can't access through the API that makes it impossible or require some obscure workaround.  This can be frustrating, as it can easily make a task you expected to take a day, take a week or even longer as you trial & error every possible approach and research a solution!

The Revit Material API is no exception.  Through the API you can create a new Material and set all its identity data, create new Thermal & Physical Assets and set all their properties, create an Appearance Asset and Apply Assets to the Material.

However, you cannot set/modify the properties of an Appearance Asset.  So how do you create high quality and "render ready" materials through the API.  Well effectively you can't...  However, what you can do is create families containing the pre-setup materials and through the API, load those families into the project and then delete them. 

As you may know, loading a family also loads all the materials and those materials will remain after you delete the family.  It also won't overwrite existing materials/assets if they already exist in the project.  So you can be sure it won't ruin any modifications a user has made.

Unfortunately if you are dealing with a Paint Manufacturer's colour palette they could have thousands of materials, and you are going to have to create all of these Appearance Assets manually using a duplicate and change the colour approach (and perhaps change the reflectivity depending on the finish).  Maybe a job for outsourcing...

Perhaps this will change in the future, but given the hundreds of different options available on Appearance Assets, I don't expect it will happen soon.