When does ProjectInformation GUID regenerate ?

When does ProjectInformation GUID regenerate ?

lvirone
Enthusiast Enthusiast
721 Views
7 Replies
Message 1 of 8

When does ProjectInformation GUID regenerate ?

lvirone
Enthusiast
Enthusiast

Hello,

 

I want to make a system which identify Revit files. I thought about using the projetInformation GUID but it seems when you save-as the new projetInformation  has the same GUID than the previous one. Too, when I generate two files using the same Revit Template, the two files have the same projetInformation GUID.

 

Am I missing something ? Is there another GUID for the model I didn't see ?

 

Thank you

 

EDIT : What worked for me : Using "ExporterIFCUtils.CreateProjectLevelGUID(doc, IFCProjectLevelGUIDType.Project)" is a good way to identify models if they are created using templates. If models are created by save-as or copy-paste, you need to add something else to identify a model like the fileName or the fullPath.

0 Likes
Accepted solutions (2)
722 Views
7 Replies
Replies (7)
Message 2 of 8

ctm_mka
Collaborator
Collaborator
Accepted solution

I believe they don't. That's sort of the point of GUID, a static identifier between projects.

0 Likes
Message 3 of 8

TripleM-Dev.net
Advisor
Advisor
Accepted solution

Hi @lvirone,

 

It won't, only elements WITHIN ONE model are unique.

Within one Revitsession each opened document will have a unique Hash value, maybe that's enough?

 

Depending on needs there are some ways; save the central document fullfilename in the model with a GUID, and on open check if it's fullpath is still identical, if not generate a new GUID that you update somewhere in the model.

 

But if the model is recreated in another location as a new central model, this would mean it will get a new GUID.

Etc...

 

- Michel

0 Likes
Message 4 of 8

lvirone
Enthusiast
Enthusiast

Hello @TripleM-Dev.net @ctm_mka 

 

Thanks for your quick answers. Yes I believe it's the correct behavior of a GUID to not change. But that's means if I create multiple projects using the same template, then all the files will have the same ProjetLocation UniqueID.

 

Yes I think the fullPath + UniqueId will be something good.

 

Thanks

0 Likes
Message 5 of 8

jeremy_tammik
Alumni
Alumni

Afaik, all the built-in project identifiers will be duplicated by copying the project file. If you want to avoid that, you will have to undertake something yourself to prevent it. The same question was discussed briefly here:

  

  

I implemented a named GUID storage for project identification that may be of use to help handle this:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 6 of 8

lvirone
Enthusiast
Enthusiast

Hi @jeremy_tammik,

 

Thank you. What do you think about using "ExporterIFCUtils.CreateProjectLevelGUID(doc, IFCProjectLevelGUIDType.Project);" to identify a project from another ?

https://www.revitapidocs.com/2024/4b93559d-3541-5740-11f1-87f202977be5.htm

 

I think this method provide a different way to generate GUID, because it didn't use the UniqueId of the ProjectInformation to generate it. It seems to be different than what you eplained here : https://thebuildingcoder.typepad.com/blog/2009/02/uniqueid-dwf-and-ifc-guid.html

 

Thanks

0 Likes
Message 7 of 8

jeremy_tammik
Alumni
Alumni

That sounds useful. It may have been implemented for the exact same purpose that you have. I have not used it myself, so I look forward to hearing how you fare with it. Thank you!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 8 of 8

lvirone
Enthusiast
Enthusiast

What works for me : Using "ExporterIFCUtils.CreateProjectLevelGUID(doc, IFCProjectLevelGUIDType.Project)" is a good way to identify models if they are created using templates. If models are created by save-as or copy-paste, you need to add something else to identify a model like the fileName or the fullPath.

0 Likes