Is there a unique and persistent identifier for a Rhino document in C#?
I want to store information about 3DM files in a database.
Currently, the only value that allows me to uniquely identify a document is its path on the file system, but the problem arises when the file is moved or renamed.
I was thinking of using the RhinoDoc.DocumentId property, but it is obsolete, and it is suggested to use RhinoDoc.RuntimeSerialNumber, which is not persistent between Rhino sessions.
I am not sure if an identifier exists, I believe you could check blobs but that would not work for identical models.
If I were you I would append custom metadata to the file with the unique identifier, you could even use doc.strings
Indeed adding your own GUID to document strings is one way to go.
But.
What happens when you copy a 3dm file? You now have two files with the same GUID. You did the copying outside of Rhino. And now the GUID is no longer… GU… You’ll have to come up with a way to identify such cases and allow for conflict resolution, update your database as you go along.
You should be able to write a plug-in that registers to the document oponing and closing events to assist you with that.
Thank you! I was worried there might not be a solution in the SDK.
So, do you know why DocumentId is now obsolete? It seemed to be persistent, didn’t it?
DocumentId returned the same number as what RuntimeSerialNumber does now. The property name wasn’t named very well, the runtime serial number property is the better named one as it reflects what the integer is actually for.