r/RevitForum • u/Beun-de-Vakker • 15d ago
Identify a model by ID through the API
Hello,
Is there a reliable way to identify a central model by an id?
Lets say
user A is working on a central file on revitserver/ACC in his own local file
User B is also working on a local copy of that central file
How can i tell that these two users are working on the same central file, preferably with something that persists when moving the central file (Central file is saved into a new directory and user A opens a local copy from there, can i tell it's the same model as before but a different location)
Thanks in advance
1
Upvotes
1
u/twiceroadsfool 15d ago
Im not 100% sure how you would have it persist when the model is moved, since (when its moved) it creates a new Central Model. It could be a new file in a new location with the same name as the old one, it could be a copy of the file thats getting used for something else, etc.
Ive seen apps try to do this (registering files within the apps) and when someone does a save-as, those apps go hella screwy, lol.
2
u/JacobWSmall 14d ago
You’ve got options depending on the details of your use case.
Current central file path is an option, but for cloud models I would recommend you use the model GUID. This won’t persist if people move things around though - save as will kill it usually.
As an alternative you could fetch model’s CreationGUID (property of the document), but if you create multiple files via ‘save as’ this can overlap in theory which would be devastatingly consistent for multiple models started by a workshared base model.
So what you really need is a way to check if a version GUID you know and care about is present in the document. If you know the version GUIDs to check for you can quickly parse out of the data is there. I am not sure if this persists across a save as, but you can pull what you need to confirm.
Validate a version GUID with the method Document.IsValidVersionGUID, and extract them with the method Document.GetDocumentVersion and pull the VersionGUID property from the DocumentVersion object you get from that.
The test you’ll have to do is to (1) pull the version GUID, (2) make a bunch of modifications and sync a few times, (3) close the model, (4) open detached and do a save as to a new central model. From there you can check if the version GUID you pulled at step 1 is valid in the model at steps 2 and 4. If so, test it with cloud models next, publishing, upgrading, downloading, opening the downloaded version, re-uploading… the whole set of actions you want to cover.
If both cloud models and local models maintain a document version GUID across all the actions you want to track then you’re down to ‘how do we get the version GUID we care about?’ as the last step. The options there are extracting from the central directly by opening the models and processing them in bulk as things happen, gathering it from the basic file info (removing the need for opening), or extracting it when you save/publish.