Getting Materials While In a Family

The previous post found the materials in the door while in the RVT project environment. Using a different approach we can get the same data while in the RFA family environment.

// Find all the GenericForm elements in the document
// GenericForm is the base class for Blend, Extrusion, Sweep, etc.
foreach (Element element in new FilteredElementCollector(doc).OfClass(typeof(GenericForm)))
    // Get the data for the Material parameter of this GenericForm
    Parameter parameter = element.get_Parameter("Material");

    // The material parameter stores an ElementId
    ElementId id = parameter.AsElementId();

    // Use this ElementId to get the Material
    Material material = doc.GetElement(id) as Material;

    // An Options object will be needed to get the geometry of the element
    // All default values are acceptable for this usage
    Options geometryOptions = new Options();

    // The GenericForm contains only one GeometryObject which is a Solid
    Solid solid = element.get_Geometry(geometryOptions).First() as Solid;

    // Collect some info about the GenericForm, Material, and Solid
    info += element.Name + ", " + material.Name + ", " + material.MaterialClass + ", " + solid.SurfaceArea + "\n";
TaskDialog.Show("Material info",info);


Here we can get a value for each extrusion used to create the family. It is nice to see that they add up to the same values as in the previous post!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s