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: 

Material Assets Collector: Appearance, Structural (Physical) & Thermal

4 REPLIES 4
Reply
Message 1 of 5
PolynineStudio
1323 Views, 4 Replies

Material Assets Collector: Appearance, Structural (Physical) & Thermal

We are trying to gather all the material assets loaded into a project file, but ran into a roadblock. We can successfully do this for the appearance assets, but for the other assets the approach does not work.

 

The only way that we can gather the structural and thermal assets is by starting with materials and cycle through the assets that are assigned. This approach will omit assets that are not assigned to materials.

 

Please see C# code below for reference. Any insight into how this can be achieved will be much appreciated.

 

 

FilteredElementCollector collector = new FilteredElementCollector(doc);
//code works for appearance assets ICollection<Element> appearanceAssets = collector.OfClass(typeof(AppearanceAssetElement)).ToElements();
//code throws an error ICollection<Element> physicalAssets = collector.OfClass(typeof(StructuralAssetClass)).ToElements();
//code throws an error ICollection<Element> physicalAssets2 = collector.OfClass(typeof(StructuralAsset)).ToElements();
//code returns zero elements ICollection<Element> propertySet = collector.OfClass(typeof(PropertySetElement)).ToElements();
//code throws an error ICollection<Element> thermalAssets = collector.OfClass(typeof(ThermalAsset)).ToElements();

 

Error:

Autodesk.Revit.Exceptions.ArgumentException: Input type(Autodesk.Revit.DB.StructuralAssetClass) is not a recognized Revit API type

4 REPLIES 4
Message 2 of 5

Additional info:

 

We are working with the Revit 2016 API for compatibility.

 

 

Other observations:

 

The reason the Appearance Assets works might be because the "AppearanceAssetElement" class is called out. Appearance asset also has the "AppearanceAsset" which seems similar to the "StructuralAsset" and "ThermalAsset" classes. However, there are no "StructuralAssetElement" or "ThermalAssetElement" classes.

 

The appearance asset also has a builtin category "OST_AppearanceAsset" while the structural or thermal assets do not have a builtin category.

 

 

 

Message 4 of 5
conoves
in reply to: PolynineStudio

Structural and Thermal Assets should be contained in PropertySetElement.  So the line you wrote filtering for that should work.  I checked in one of our templates and found 62 elements matching the filter.  

 

 



Scott Conover

Senior Engineering Manager, Revit

Message 5 of 5
PolynineStudio
in reply to: conoves

Scott,

 

 

Thank you for your direction. The reason zero elements were collected in our previous code was because we used the same collector element for the appearance assets and the propertySet. As soon as we defined a new one "collector2", it worked.

 

The  propertySet element hosts thermal and structural assets. However, there can be two property sets that have the same name (Air for example) and one property set is dedicated to the structural while the other to the thermal. You cannot easily discern whether setting the property set element to a material will set the thermal or structural assets. Essentially, the property set is either thermal or structural when applied to a material.

 

It seems like the Revit UI categorizes propertysets further into thermal and structural categories, while API access is limited.

 

Below is an attempt to try to categorize the propertyset elements. Some property sets return a null value when the thermal asset info is missing and vice-versa. 

 

 

//property set: thermal and structural
            FilteredElementCollector collector2 = new FilteredElementCollector(doc);
            ICollection<Element> propertySet = collector2.OfClass(typeof(PropertySetElement)).ToElements();
            
            //loop through property sets to gather structural and thermal assets
            foreach (PropertySetElement psEle in propertySet)
            {
                try
                {
                    //gather
                    StructuralAsset structAsset = psEle.GetStructuralAsset();

                    //process - currently add both aspects of property set if they exist
                    //this method can have same p-set element id in both thermal and structural
                    if (structAsset != null)
                    {
                        structuralAssets.Add(psEle);
                    }
                }
                catch
                {
                    //code
                }
                try
                {
                    //gather
                    ThermalAsset thermAsset = psEle.GetThermalAsset();

                    //process - currently add both aspects of property set if they exist
                    //this method can have same p-set element id in both thermal and structural
                    if (thermAsset != null)
                    {
                        thermalAssets.Add(psEle);
                    }
                }
                catch
                {
                    //code
                }

            }

 

 

The image below shows the ThermalAsset data extracted from a propertySet originally assigned to a StructuralAssetID of a material.

 

pr.png

 

If the propertyset elements that host primarily the structural assets can be separated from the ones that host the thermal assets, then we would have to lists of property sets that we can work with.

 

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