TryParse Method


Parse the string representation of the id into a corresponding ElementId.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Since: 2023

Syntax

C#
public static bool TryParse(
	string idStr,
	out ElementId id
)
Visual Basic
Public Shared Function TryParse ( _
	idStr As String, _
	<OutAttribute> ByRef id As ElementId _
) As Boolean
Visual C++
public:
static bool TryParse(
	String^ idStr, 
	[OutAttribute] ElementId^% id
)

Parameters

idStr
Type: SystemString
The string representation of the id to return.
id
Type: Autodesk.Revit.DBElementId%
Out parameter set to the ElementId represented by the string.

Return Value

true if the string was successfully parsed into an ElementId, false otherwise.

Remarks

If the string represents [!:Autodesk::Revit::DB::Element::InvalidElementId] the id will contain it upon return. If the parse fails, the id will be undefined.

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →