Jump to content

Get File Unique ID


Recommended Posts

I've written a plugin that collects a bunch of object data and pushes it out as a database, where a non-Vectorworks user can edit it. It can then be re-imported and the relevant objects get updated.

 

I'd like the plugin to get the unique ID of the VW file and store it in the outgoing database, so if someone imports it back to the wrong VW file, it can say "This isn't the Vectorworks file your database was exported from. Give yourself a talking-to'.

 

I've had a look through the function reference and I can get the VW file name, but not really a primary key for it. It might be a GetObjectUUID, but I don't know how to get the handle of the file itself (if there is such a thing).

 

Thanks!

Link to comment

I don't think there is a UUID for the file. And wouldn't you really like to be able to import the file back in even if someone had duplicated the file (which should change the UUID?)

 

What about doing your own check.  Use CreateUUID and store that value in a record. Maybe attach the record to the None class so it is unlikely to be deleted/changed by a user. Then you could use your created UUID to do your comparison.  Also by doing your own, the UUID stored in a record will remain the same even when the file is duplicated so you would still be able to re-import into that file.

 

???

  • Like 1
Link to comment

I don't think there is a UUID for the file. And wouldn't you really like to be able to import the file back in even if someone had duplicated the file (which should change the UUID?)

 

What about doing your own check.  Use CreateUUID and store that value in a record. Maybe attach the record to the None class so it is unlikely to be deleted/changed by a user. Then you could use your created UUID to do your comparison.  Also by doing your own, the UUID stored in a record will remain the same even when the file is duplicated so you would still be able to re-import into that file.

 

???

Link to comment
30 minutes ago, Pat Stanford said:

I don't think there is a UUID for the file. And wouldn't you really like to be able to import the file back in even if someone had duplicated the file (which should change the UUID?)

 

What about doing your own check.  Use CreateUUID and store that value in a record. Maybe attach the record to the None class so it is unlikely to be deleted/changed by a user. Then you could use your created UUID to do your comparison.  Also by doing your own, the UUID stored in a record will remain the same even when the file is duplicated so you would still be able to re-import into that file.

 

???

Thanks. In this application in our office, I want to make sure it's the very same file and not a duplicate. Even if it ends up needing that ability to be reimported to a duplicate, maybe for a corruption or something, it will need a strong warning to say its not the original file.

 

I'll have a think how else I could do it. Cheers

Link to comment

If it needs to be the very same file, then I think storing a UUID + a date/time string to both the source file and the exported file and them comparing them on the way back in would be enough.

 

The only issue I could see then would be you do an export and it sets the date/time. Someone then does a second export and overwrites the date/time so the person editing the first file would be told the files don't match.

 

mumble, mumble, mumble something about foolproof and better fools. 😉

  • Like 1
Link to comment

Files definitely do not have unique id’s. In fact, I think that’s a feature— if you were to save a backup or a named version, you would want the file to be identified the same. 
 

Storing a UUID in a hidden record would be the way to go, but you would need some kind of manual connection setup between the file and database. 

  • Like 1
Link to comment

Thanks guys.

 

I'm planning this for an office environment with maybe 15-20 users of varied skill, some of which have opposable thumbs and good discipline, and others may be unintentionally rogue with taking copies of their project's master Vectorworks file from the server. We're not using Project Sharing (yet) for a few reasons, and our current server and file management works well for us, I'm just trying to consider the edge cases where user has saved a copy locally on their machine without knowing.

 

Like you say, the fact that a stored UUID carries to a duplicate will help most users though, in the case of backups/corruption etc.

 

I like the idea of a hidden record - for this and other things. @JBenghiat is there anything to know with making a record hidden, please? From what I can see it involves a double underscore, but I don't know if that's a cause or a symptom.

 

Thank you

Link to comment
1 hour ago, spettitt said:

I like the idea of a hidden record - for this and other things. @JBenghiat is there anything to know with making a record hidden, please? From what I can see it involves a double underscore, but I don't know if that's a cause or a symptom.

The double underscore will hide a field. To hide a record, use SetObjectVariableBoolean on the record format with the selector 900. (True is hidden). Usually I check if the record exists, if not, create it, then hide. The record otherwise functions as usual, and you can create a script to toggle visibility as you're testing.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...