Duplicates the material
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic Material Duplicate(
string name
)
Public Function Duplicate (
name As String
) As Material
public:
Material^ Duplicate(
String^ name
)
member Duplicate :
name : string -> Material
Parameters
- name String
-
Name of the new material - this name must be correctly structured for Revit use and not duplicate the name
of another material in the document.
Return Value
Material
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
|
Remarks
If duplication fails for reasons unrelated to the name, will be returned.
Exampleprivate bool DuplicateMaterial(Material material)
{
bool duplicated = false;
string newName = "new" + material.Name;
Material myMaterial = material.Duplicate(newName);
if (null == myMaterial)
{
TaskDialog.Show("Revit", "Failed to duplicate a material!");
}
else
{
duplicated = true;
}
return duplicated;
}
Private Function DuplicateMaterial(material As Material) As Boolean
Dim duplicated As Boolean = False
Dim newName As String = "new" & Convert.ToString(material.Name)
Dim myMaterial As Material = material.Duplicate(newName)
If myMaterial Is Nothing Then
TaskDialog.Show("Revit", "Failed to duplicate a material!")
Else
duplicated = True
End If
Return duplicated
End Function
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