How do you access a model's GUID or UniqueId using the Revit API?

How do you access a model's GUID or UniqueId using the Revit API?

Anonymous
Not applicable
3,398 Views
2 Replies
Message 1 of 3

How do you access a model's GUID or UniqueId using the Revit API?

Anonymous
Not applicable

I'm trying to uniquely identify a Revit model (get a project's GUID), which I presume would mean using a Document's UniqueId. The following returns the same string, regardless of what model is active:

 

uiApp.ActiveUIDocument.Document.ProjectInformation.UniqueId;

 ... where uiApp is the UIApplication from ExternalCommandData.Application. I've also noticed that the string returned is the same even between Revit sessions and creating new projects from scratch.

 

Any help would be appreciated!

0 Likes
Accepted solutions (1)
3,399 Views
2 Replies
Replies (2)
Message 2 of 3

Joe.Ye
Alumni
Alumni

 

Yes, I can confirm that the UniqueId property for some Revit documents are identical, I also found that some Revit documents have different GUID.

 

So you may need to add a shared parameter , and store the newly generated GUID for that project.

 

Hope this helps.



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 3 of 3

Anonymous
Not applicable
Accepted solution

Joe,

 

Thanks for confirming. I ended up adding my own GUID to the document element using the Revit extensible storage tools. I'd imagine a shared parameter would certainly work, too.

 

Regards,

Adam

 

0 Likes