GlobalParametersManager.FindByName
Description:
Finds whether a global parameter with the given name exists in the input document.
Finds whether a global parameter with the given name exists in the input document.
Remarks:
No exception is thrown when no parameter with such a name exists in the document; instead, the method returns an ElementId.InvalidElementId.
No exception is thrown when no parameter with such a name exists in the document; instead, the method returns an ElementId.InvalidElementId.
-
documentThe document expected to contain the global parameter.
-
StringnameName of the global parameter
/// <summary>
/// Tries to find a global parameter by its name.
/// </summary>
/// <param name="document">Revit project document.</param>
/// <param name="name">Name of a global parameter.</param>
/// <returns>An Element Id of the global parameter, or InvalidElementId if none found</returns>
public ElementId GetGlobalParameterByName(Document document, String name)
{
// Global parameters are not available in all documents.
// They are available in projects, but not in families.
if (GlobalParametersManager.AreGlobalParametersAllowed(document))
{
return GlobalParametersManager.FindByName(document, name);
}
// return an empty set if global parameters are not available in the document
return ElementId.InvalidElementId;
}
-
A non-optional argument was null