Creates a new material.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic static ElementId Create(
Document document,
string name
)
Public Shared Function Create (
document As Document,
name As String
) As ElementId
public:
static ElementId^ Create(
Document^ document,
String^ name
)
static member Create :
document : Document *
name : string -> ElementId
Parameters
- document Document
-
The document in which to create the material.
- name String
-
The name of the new material.
Return Value
ElementId
Identifier of the new material.
ExceptionsException | Condition |
---|
ArgumentException |
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.
|
ArgumentNullException |
A non-optional argument was null
|
Example
ElementId materialId = Material.Create(document, "My Material");
Material material = document.GetElement(materialId) as Material;
StructuralAsset strucAsset = new StructuralAsset("My Property Set", StructuralAssetClass.Concrete);
strucAsset.Behavior = StructuralBehavior.Isotropic;
strucAsset.Density = 232.0;
PropertySetElement pse = PropertySetElement.Create(document, strucAsset);
material.SetMaterialAspectByPropertySet(MaterialAspect.Structural, pse.Id);
Dim materialId As ElementId = Material.Create(document, "My Material")
Dim material__1 As Material = TryCast(document.GetElement(materialId), Material)
Dim strucAsset As New StructuralAsset("My Property Set", StructuralAssetClass.Concrete)
strucAsset.Behavior = StructuralBehavior.Isotropic
strucAsset.Density = 232.0
Dim pse As PropertySetElement = PropertySetElement.Create(document, strucAsset)
material__1.SetMaterialAspectByPropertySet(MaterialAspect.Structural, pse.Id)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also