Create Method


Creates a new material.

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

Syntax

C#
public static ElementId Create(
	Document document,
	string name
)
Visual Basic
Public Shared Function Create ( _
	document As Document, _
	name As String _
) As ElementId
Visual C++
public:
static ElementId^ Create(
	Document^ document, 
	String^ name
)

Parameters

document
Type: Autodesk.Revit.DBDocument
The document in which to create the material.
name
Type: SystemString
The name of the new material.

Return Value

Identifier of the new material.

Examples

CopyC#
//Create the material
ElementId materialId = Material.Create(document, "My Material");
Material material = document.GetElement(materialId) as Material;

//Create a new property set that can be used by this material
StructuralAsset strucAsset = new StructuralAsset("My Property Set", StructuralAssetClass.Concrete);
strucAsset.Behavior = StructuralBehavior.Isotropic;
strucAsset.Density = 232.0;

//Assign the property set to the material.
PropertySetElement pse = PropertySetElement.Create(document, strucAsset);
material.SetMaterialAspectByPropertySet(MaterialAspect.Structural, pse.Id);
CopyVB.NET
'Create the material
Dim materialId As ElementId = Material.Create(document, "My Material")
Dim material__1 As Material = TryCast(document.GetElement(materialId), Material)

'Create a new property set that can be used by this material
Dim strucAsset As New StructuralAsset("My Property Set", StructuralAssetClass.Concrete)
strucAsset.Behavior = StructuralBehavior.Isotropic
strucAsset.Density = 232.0

'Assign the property set to the material.
Dim pse As PropertySetElement = PropertySetElement.Create(document, strucAsset)
material__1.SetMaterialAspectByPropertySet(MaterialAspect.Structural, pse.Id)

Exceptions

ExceptionCondition
Autodesk.Revit.ExceptionsArgumentException name cannot include prohibited characters, such as "{, }, [, ], |, ;, less-than sign, greater-than sign, ?, `, ~". -or- The given value for name is already in use as a material element name.
Autodesk.Revit.ExceptionsArgumentNullException A non-optional argument was null

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 →