How to Not Open a Local File’s Central File

The last post about errors when synchronizing with the central file got me thinking about how the API might be used to run checks in the central file before saving.

At first, it seems like it should be simple to open the local file’s central file. Maybe it should be, but it isn’t.

Here is a straightforward first attempt. The user opens the local file. Then this macro runs to open and investigate the central file.

public void OpenCentralFile()
    Document doc = this.ActiveUIDocument.Document;

    // Get an instance of the ModelPath class describing the central file
    ModelPath modelPath = doc.GetWorksharingCentralModelPath();

    // Get the string of the path for the modelPath 
    string centralFilepath = ModelPathUtils.ConvertModelPathToUserVisiblePath(modelPath);

    Autodesk.Revit.ApplicationServices.Application app = this.Application;
    // Open the Central File
    Document centralDoc = app.OpenDocumentFile(centralFilepath);

    // We never get here because the local and central can't both be open at the same time in the same session
    TaskDialog.Show("status", "Central file opened");


Revit users may have seen this restriction in the past, and with the API the restriction is no different. The next post will look at how to workaround this limitation.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s