Create Method (Document, String, ForgeTypeId)


Creates a new Global Parameter in the given document.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 22.0.0.0 (22.1.0.0)
Since: 2016 Subscription Update

Syntax

C#
public static GlobalParameter Create(
	Document document,
	string name,
	ForgeTypeId specTypeId
)
Visual Basic
Public Shared Function Create ( _
	document As Document, _
	name As String, _
	specTypeId As ForgeTypeId _
) As GlobalParameter
Visual C++
public:
static GlobalParameter^ Create(
	Document^ document, 
	String^ name, 
	ForgeTypeId^ specTypeId
)

Parameters

document
Type: Autodesk.Revit.DB Document
Document in which the new parameter is to be created
name
Type: System String
The name of the new parameter. It must be unique in the document
specTypeId
Type: Autodesk.Revit.DB ForgeTypeId
Identifier of the spec describing the parameter's data type.

Return Value

An instance of the new global parameter

Remarks

Global parameters may be created only in Project documents, not in families.

Each global parameter must have a valid name that is unique within the document. To test whether a name is unique, use the IsUniqueName(Document, String) method.

While global parameters can be created with almost any type of data, there is a few types that are not currently supported, such as the ElementId type. Programmers can test whether a particular data type is appropriate for a global parameter by using the IsValidDataType(ParameterType) method.

Parameters are created as non-reporting initially, but programmers are free to modify the IsReporting property once a global parameter is created and happens to be of a type eligible for reporting.

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException Global parameters are not supported in the given document. A possible cause is that it is not a project document, for global parameters are not supported in Revit families. -or- name is an empty string. -or- name cannot include prohibited characters. -or- A global parameter with the given name already exists in the document. -or- specTypeId is not a spec identifier.
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was null

See Also