Identify the associated building structural elements for the propertySetElement

Identify the associated building structural elements for the propertySetElement

Anonymous
Not applicable
499 Views
1 Reply
Message 1 of 2

Identify the associated building structural elements for the propertySetElement

Anonymous
Not applicable

The following code works fine for getting all "PropertySetElements" in a Revit document. 

But, I have to identify the associated building structural elements for the propertySetElement. Any suggestions? 

 

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

Type test = psEle.GetType();
string test_1 = psEle.ToString();

//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.Behavior == StructuralBehavior.Isotropic)
{
// Get the class of material
StructuralAssetClass assetClass = structAsset.StructuralAssetClass; // Get other material properties

// Get other material properties
double poisson = structAsset.PoissonRatio.X;
double youngMod = structAsset.YoungModulus.X;
double thermCoeff = structAsset.ThermalExpansionCoefficient.X;
double unitweight = structAsset.Density;
double shearMod = structAsset.ShearModulus.X;
double dampingRatio = structAsset.DampingRatio;
if (assetClass == StructuralAssetClass.Metal)
{
double dMinStress = structAsset.MinimumYieldStress;
}
else if (assetClass == StructuralAssetClass.Concrete)
{
double dConcComp = structAsset.ConcreteCompression;
}
}
}
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.ThermalMaterialType == ThermalMaterialType.Solid)
{
// thermalAssets.Add(psEle);
// Get the properties which are supported in solid type
bool isTransmitsLight = thermAsset.TransmitsLight;
double permeability = thermAsset.Permeability;
double porosity = thermAsset.Porosity;
double reflectivity = thermAsset.Reflectivity;
double resistivity = thermAsset.ElectricalResistivity;
StructuralBehavior behavior = thermAsset.Behavior;

// Get the other properties.
double heatOfVaporization = thermAsset.SpecificHeatOfVaporization;
double emissivity = thermAsset.Emissivity;
double conductivity = thermAsset.ThermalConductivity;
double density = thermAsset.Density;
}
}
catch
{
//code
}
}

0 Likes
500 Views
1 Reply
Reply (1)
Message 2 of 2

JimJia
Alumni
Alumni

Dear Vijaya Adigopula,

 

Please accept our sincerer apology for the delay! We had a backlog in the queue.

 

We can get Material from element firstly, and then verify if StructuralAssetId or ThermalAssetId is given PropertySetElement.

 

Following code demonstrates how to find all instance elements whose structural or thermal material asset is given PropertySetElement.

        /// <summary>
        /// Finds all associated elemennts whose structural or thermal material asset is given PropertySetElement
        /// </summary>
        /// <param name="psElem"></param>
        /// <returns></returns>
        List<ElementId> findAssociatedElements(PropertySetElement psElem)
        {
            // find all instance elements within document
            List<ElementId> elemIds = new List<ElementId>();
            FilteredElementCollector coll = new FilteredElementCollector(psElem.Document);
            foreach(var elem in coll.WhereElementIsNotElementType().ToElements())
            {
                var materials = elem.GetMaterialIds(false).ToList();
                if (!materials.Any())
                    continue;
                Material mat = psElem.Document.GetElement(materials[0]) as Material;
                //
                // Element's StructuralAsset is desired PropertySetElement
                if (mat.StructuralAssetId == psElem.Id)
                    elemIds.Add(elem.Id);
                // Element's Thermal is desired PropertySetElement
                if (mat.ThermalAssetId == psElem.Id)
                    elemIds.Add(elem.Id);
            }
            return elemIds;
        }

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: [email protected]
0 Likes