Material Class


Represents a material element within an Autodesk Revit project.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)

Syntax

C#
public class Material : Element
Visual Basic
Public Class Material _
	Inherits Element
Visual C++
public ref class Material : public Element

Remarks

This is the parent class for concrete material subclasses. Currently, the supported materials are wood, steel, generic, concrete and other.

Examples

Copy C#
private void GetMaterialInformation(Material material)
{
   StringBuilder message = new StringBuilder("Material : " + material.Name);
   //color of the material
   message.Append(string.Format("\nColor: Red[{0}]; Green[{1}]; Blue[{2}]",
                   material.Color.Red, material.Color.Green, material.Color.Blue));

   //cut pattern and pattern color of the material

   FillPatternElement cutPattern = material.Document.GetElement(material.CutPatternId) as FillPatternElement;
   if (null != cutPattern)
   {
      message.Append("\nCut Pattern: " + cutPattern.Name);
      message.Append(string.Format("\nCut Pattern Color: Red[{0}]; Green[{1}]; Blue[{2}]",
                      material.CutPatternColor.Red, material.CutPatternColor.Green, material.CutPatternColor.Blue));
   }

   //surface pattern and pattern color of the material
   FillPatternElement surfacePattern = material.Document.GetElement(material.SurfacePatternId) as FillPatternElement;
   if (null != surfacePattern)
   {
      message.Append("\nSurface Pattern: " + surfacePattern.Name);
      message.Append(string.Format("\nSurface Pattern Color: Red[{0}]; Green[{1}]; Blue[{2}]",
                      material.SurfacePatternColor.Red, material.SurfacePatternColor.Green, material.SurfacePatternColor.Blue));
   }

   //some shading property of the material
   bool glow = material.Glow;
   message.Append("\nMaterial can glow: " + glow);
   int shininess = material.Shininess;
   message.Append("\nShininess: " + shininess);
   int smoothness = material.Smoothness;
   message.Append("\nSmoothness: " + smoothness);
   int transparency = material.Transparency;
   message.Append("\nTransparency: " + transparency);

   TaskDialog.Show("Revit", message.ToString());
}
Copy VB.NET
Private Sub GetMaterialInformation(material As Material)
    Dim message As New StringBuilder("Material : " & Convert.ToString(material.Name))
    'color of the material
    message.Append(String.Format(vbLf & "Color: Red[{0}]; Green[{1}]; Blue[{2}]", material.Color.Red, material.Color.Green, material.Color.Blue))

    'cut pattern and pattern color of the material


    Dim cutPattern As FillPatternElement = TryCast(material.Document.GetElement(material.CutPatternId), FillPatternElement)
    If cutPattern IsNot Nothing Then
        message.Append(vbLf & "Cut Pattern: " + cutPattern.Name)
        message.Append(String.Format(vbLf & "Cut Pattern Color: Red[{0}]; Green[{1}]; Blue[{2}]", material.CutPatternColor.Red, material.CutPatternColor.Green, material.CutPatternColor.Blue))
    End If

    'surface pattern and pattern color of the material
    Dim surfacePattern As FillPatternElement = TryCast(material.Document.GetElement(material.SurfacePatternId), FillPatternElement)
    If surfacePattern IsNot Nothing Then
        message.Append(vbLf & "Surface Pattern: " + surfacePattern.Name)
        message.Append(String.Format(vbLf & "Surface Pattern Color: Red[{0}]; Green[{1}]; Blue[{2}]", material.SurfacePatternColor.Red, material.SurfacePatternColor.Green, material.SurfacePatternColor.Blue))
    End If

    'some shading property of the material
    Dim glow As Boolean = material.Glow
    message.Append(vbLf & "Material can glow: " & glow)
    Dim shininess As Integer = material.Shininess
    message.Append(vbLf & "Shininess: " & shininess)
    Dim smoothness As Integer = material.Smoothness
    message.Append(vbLf & "Smoothness: " & smoothness)
    Dim transparency As Integer = material.Transparency
    message.Append(vbLf & "Transparency: " & transparency)

    TaskDialog.Show("Revit", message.ToString())
End Sub

Inheritance Hierarchy

See Also

ArchiLabs Desktop

Put AI to work inside Revit.

Give Desktop your instructions and project files to build Revit families, update model elements, and create views and schedules. Works directly in Revit and AutoCAD.

Explore Desktop →