PropertySetElement contains structural or thermal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm working on being able to create material physical and thermal assets. I have it pretty well working but it's painfully slow because of how I need to check for existing (or at least how I think I do). Based on what I have found on this link and others there is no way to tell if a property set element contains structural and/or thermal assets except to try and get them and let it throw an exception if it doesn't. That's terribly inefficient and makes things really slow... I did create it so that it caches the assets up front and then uses that so that it doesn't have to keep going back during the process which helps a lot, but still slows it down quite a bit. Here is my code to sort out the assets:
_physicalAssets = new List<StructuralAsset>();
_thermalAssets = new List<ThermalAsset>();
foreach (PropertySetElement pse in new FilteredElementCollector(doc).OfClass(typeof(PropertySetElement)))
{
try
{
var sa = pse.GetStructuralAsset();
if (sa != null) _physicalAssets.Add(sa);
}
catch
{
}
try
{
var ta = pse.GetThermalAsset();
if (ta != null) _thermalAssets.Add(ta);
}
catch
{
}
}Have there been any updates that I missed that allows us to determine this without the try block? Is there any better way to do this? If I create another asset with the same name I assume it will either throw an error or create a duplicate correct?
