Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 67020

Re: Open a file if central model cannot be found

$
0
0

The error might be related to this function call, but I didn't see it in your code snippet, it requires Network connection to the central file with my experience.

WorksharingUtils.GetUserWorksetInfo(revitCentralFile)

 

 

If you want to preserve worksets, you can set WorksetConfiguration to OpenLastViewed, it's the default option of the Revit OpenFileDialog with my finding.

DetachCentral.jpg

 

Here is my test code. It works as expected and the result is the same as the Revit OpenFileDialog does.

 

public void CreateSaveDetachedFile2(UIApplication application, string revitFilePath)
{
    //Get information of current opened revit file
    FileInfo filePath = new FileInfo(revitFilePath);
    ModelPath revitCentralFile = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath.FullName);

    var openConfig = new WorksetConfiguration(WorksetConfigurationOption.OpenLastViewed);

    OpenOptions openOptions = new OpenOptions();
    openOptions.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets;
    openOptions.Audit = false;
    openOptions.AllowOpeningLocalByWrongUser = true;
    openOptions.SetOpenWorksetsConfiguration(openConfig);

    application.OpenAndActivateDocument(revitCentralFile, openOptions, false);
}

Hope it helps.

 


Viewing all articles
Browse latest Browse all 67020

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>