Tests whether a name is unique among existing global parameters of a given document.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Since:
2016 Subscription Update
Syntax
C# |
---|
public static bool IsUniqueName(
Document document,
string name
) |
Visual Basic |
---|
Public Shared Function IsUniqueName ( _
document As Document, _
name As String _
) As Boolean |
Visual C++ |
---|
public:
static bool IsUniqueName(
Document^ document,
String^ name
) |
Parameters
- document
- Type: Autodesk.Revit.DB..::..Document
Document in which a new parameter is to be added.
- name
- Type: System..::..String
A name of a parameter being added.
Return Value
True if the given %name% does not exist yet among existing global parameters nof the document; False otherwise.
Remarks
Examples
CopyC#
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;
}
CopyVB.NET
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
Exceptions
See Also