GlobalParametersManagerIsUniqueName Method |
Tests whether a name is unique among existing global parameters of a given document.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic static bool IsUniqueName(
Document document,
string name
)
Public Shared Function IsUniqueName (
document As Document,
name As String
) As Boolean
public:
static bool IsUniqueName(
Document^ document,
String^ name
)
static member IsUniqueName :
document : Document *
name : string -> bool
Parameters
- document Document
-
Document in which a new parameter is to be added.
- name String
-
A name of a parameter being added.
Return Value
Boolean
True if the given %name% does not exist yet among existing global parameters nof the document; False otherwise.
Exceptions
Remarks
Typically, this method is used before a new global parameters is created, for
all global parameters must have their names unique in the scope of a document.
Example
public GlobalParameter GetOrCreateAGlobalParameter(Document document, String name)
{
GlobalParameter gp = null;
if (GlobalParametersManager.AreGlobalParametersAllowed(document))
{
if (GlobalParametersManager.IsUniqueName(document,name))
{
gp = document.GetElement(GlobalParametersManager.FindByName(document, name)) as GlobalParameter;
}
else
{
using (Transaction trans = new Transaction(document, "Create Global Parameter"))
{
trans.Start();
gp = GlobalParameter.Create(document,name, SpecTypeId.Number);
trans.Commit();
}
}
}
return gp;
}
Public Function GetOrCreateAGlobalParameter(document As Document, name As [String]) As GlobalParameter
Dim gp As GlobalParameter = Nothing
If GlobalParametersManager.AreGlobalParametersAllowed(document) Then
If GlobalParametersManager.IsUniqueName(document, name) Then
gp = TryCast(document.GetElement(GlobalParametersManager.FindByName(document, name)), GlobalParameter)
Else
Using trans As New Transaction(document, "Create Global Parameter")
trans.Start()
gp = GlobalParameter.Create(document, name, SpecTypeId.Number)
trans.Commit()
End Using
End If
End If
Return gp
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