Material.Duplicate
Description:
Duplicates the material
Duplicates the material
Remarks:
If duplication fails for reasons unrelated to the name, null will be returned.
If duplication fails for reasons unrelated to the name, null will be returned.
public Material Duplicate(
string name
)
private bool DuplicateMaterial(Material material)
{
bool duplicated = false;
//try to duplicate a new instance of Material class using duplicate method
//make sure the name of new material is unique in MaterailSet
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;
}
-
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.
-
A non-optional argument was null