How to access IDs and UniqueIDs of Revit elements using PropertyWizard

This is a quick post describing the Id and UniqueId properties in Revit, and showing how to access them using PropertyWizard.

Every Revit element has an Id property and also a UniqueId property, highlighted here in RevitLookup:

Revit Lookup window highlighting the Id and UniqueId properties on a Revit element

The Id is ‘A unique identifier for an Element in an Autodesk Revit project.’ and ‘… an object containing the project-wide unique identifier for this Element. The identifier with this id is only unique for the project, it is not unique across separate Autodesk Revit projects.’ See Revit API Docs for more details.

And the UniqueId is ‘A stable unique identifier for an element within the document.’ and ‘… can be used to store an identifier in an external database and to retrieve the same element in the future if it still exists. The UniqueId is stable across upgrades and workset operations such as Save To Central, while the ElementId property may change.’ and again, see more on Revit API Docs.

The key difference between the two is that the Id can change when a project is synchronised or saved, while the UniqueId is set when the element is created and will never change.

UniqueIds are not shown anywhere in the Revit UI, but Ids do show up in a few places. They appear in the Warnings dialog:

Revit Warnings dialog highlighting element Ids

And you can use the ‘IDs of Selection’ and ‘Select by ID’ commands from the Manage tab to show them and select with them:

Revit Inquiry panel from the Manage tab, showing the commands 'IDs of Selection', 'Select by ID', and 'Warnings'

How to access Id and UniqueId in PropertyWizard

It is easy to copy the Id and UniqueId properties into a standard text parameter using PropertyWizard. The Help PDF, in ‘Getting Started’ section L, shows how to access the Id property. You just type the property name ‘Id’ (without the quotes) in the formula field:

PropertyWizard Formula window showing a formula for the category 'Walls', Target Property is DWD_Id' and the Formula text is 'Id'

The UniqueId is just as easy:

PropertyWizard Formula window showing a formula for the category 'Walls', Target Property is 'DWD_UniqueId' and the Formula text is 'UniqueId'

In both cases, the target parameter should be a text parameter. The Id may look like an integer, but it’s actually an ElementId object. In theory, PropertyWizard could have the ability to convert ElementIds into integers – let me know if that would be useful to you. Similarly, UniqueIds look like Guids, but they are stored as text strings and they are not globally unique (if you copy a Revit file in Windows Explorer, the UniqueIds of the elements in the two copies will be identical)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.