ConvertToStableRepresentation Method


Converts the reference to a stable String representation.

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

Syntax

C#
public string ConvertToStableRepresentation(
	Document document
)
Visual Basic
Public Function ConvertToStableRepresentation ( _
	document As Document _
) As String
Visual C++
public:
String^ ConvertToStableRepresentation(
	Document^ document
)

Parameters

document
Type: Autodesk.Revit.DBDocument
The document.

Remarks

The stable representation can be used to preserve and restore the reference later in the same Revit session or even in a different session where the same document is present. Use ParseFromStableRepresentation(Document, String) to restore the reference. The representation is based on the internal Revit structure and is not intended to be parsed expect by ParseFromStableRepresentation(Document, String).

Examples

CopyC#
public string SerializeReference(Document doc, Reference reference)
{
    String ids = String.Empty;
    ids = reference.ConvertToStableRepresentation(doc);
    TaskDialog.Show("SerializeReference", "Representation:\n" + ids);
    return ids;
}
CopyVB.NET
Public Function SerializeReference(doc As Document, reference As Reference) As String
    Dim ids As [String] = [String].Empty
    ids = reference.ConvertToStableRepresentation(doc)
    TaskDialog.Show("SerializeReference", "Representation:" & vbLf + ids)
    Return ids
End Function

Exceptions

ExceptionCondition
Autodesk.Revit.ExceptionsArgumentNullExceptiondocument was a null reference (Nothing in Visual Basic).
Autodesk.Revit.ExceptionsInvalidObjectExceptionReference contained element ids not found in this document.

See Also