API code to open a Group file as read only (bc someone else might have it open)

API code to open a Group file as read only (bc someone else might have it open)

Anonymous
Not applicable
518 Views
2 Replies
Message 1 of 3

API code to open a Group file as read only (bc someone else might have it open)

Anonymous
Not applicable

We have a custom addin to load in multiple Revit Group files into a project with a click of a button. However, if someone in the office has one of the Revit Groups open, we get an error and it doesn't execute. Is there any API code out there that enables us to select the Groups we want to load in and if the group is open somewhere else, it will open the groups as "read only" files instead of giving us an error because it's open? 

0 Likes
519 Views
2 Replies
Replies (2)
Message 2 of 3

RPTHOMAS108
Mentor
Mentor

Don't know what you mean by group file to be honest.

 

You could create a file open token in the same location as the group file i.e. you add handler for document opened and closed to create the token file, delete the token file respectively. Add handler to handle family loading and if token file exists then cancel event.

 

However probably better and easier to correct the code that leaves an unhandled exception in the first place.

 

 

0 Likes
Message 3 of 3

jeremytammik
Autodesk
Autodesk

Dear Stephen,

 

Thank you for your query.

 

Have you checked what the Windows API says about the read-only, read-write etc. file access rights to the file?

 

Maybe you can use that information to detect that Revit has the file open and has locked it down somehow, preventing further access from other parties.

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes