Accesssing and Filtering by Ramp Material

I had a chat with Ning Zhou, who was away from the Revit API for a while and is now happily back in the fold.

He explored how to access the material of a ramp element.

Access to Ramp Material

Question: Is there a way to get the ramp material information using API? I tried lots of paths and could not find anything.

Answer (by Ning himself): I searched again using RevitLookup snoop.

It turns out that basic material info is accessible after all. I found it us under 'Object type' instead of 'Parameters'. Apparently only the material name is stored there, in the built-in parameter 'RAMP_ATTR_MATERIAL':

Snoop ramp material

I have not seen anything providing the material volume, so I guess I'll have to use the geometry access and calculate that myself instead.

At least I can now implement a filter selection using the material name!

  FilteredElementCollector concreteRamps
    = new FilteredElementCollector( doc )
      .WhereElementIsNotElementType()
      .OfCategory( BuiltInCategory.OST_Ramps )
      .Where( e =>
      {
        ElementId id = e.GetValidTypes().First(
          id2 => id2.Equals( e.GetTypeId() ) );
 
        Material m = doc.GetElement( doc.GetElement( id )
          .get_Parameter(
            BuiltInParameter.RAMP_ATTR_MATERIAL )
          .AsElementId() ) as Material;
 
        return m.Name.Contains( "Concrete" );
      } );

Many thanks to Ning for his research and sharing this helpful result.

Addendum: Simpler:

  FilteredElementCollector concreteRamps
    = new FilteredElementCollector( doc )
      .WhereElementIsNotElementType()
      .OfCategory( BuiltInCategory.OST_Ramps )
      .Where( e =>
      {
        ElementId id = e.GetTypeId();
 
        Material m = doc.GetElement( doc.GetElement( id )
          .get_Parameter(
            BuiltInParameter.RAMP_ATTR_MATERIAL )
          .AsElementId() ) as Material;
 
        return m.Name.Contains( "Concrete" );
      } );

Thank you again, Ning, for you your additional comment below.

Before closing, here is another useful pointer on family instance placement and rotation:

Rotate a Family in Three Different Axes

Here is a pretty neat article on family instance placement strategies from a user point of view, describing how to rotate a family in three different axes, which is certainly useful for developers as well.

As always in the Revit API, knowing the best practice from a user and product point of view is of paramount importance before putting any thoughts or efforts at all into API development issues.