Opening a local file’s central file – Attempt #2

public void OpenCentralFile()
    Autodesk.Revit.ApplicationServices.Application app = this.Application;
    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);

    // Local and central can't both be open at the same time in the same session
    // But trying to call doc.Close() here doesn't work. It throws an InvalidOperationException
    // when attempting to close the currently active document

    Document centralDoc = app.OpenDocumentFile(centralFilepath);
    TaskDialog.Show("status", "Central file opened");

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 )

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