Message 1 of 17
Open a file if central model cannot be found

Not applicable
06-01-2018
06:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I need to open a file with Detach from central option via Revit API.
The problem is that I'm getting CentralFileCommunicationException and opening is failed.
The behavior looks strange to me. I want to open and detach, so it absolutely does not matter for me if central model available or not.
At the same time, if I open this file in UI, I also get this dialog, but I can just close it and continue.
Is there a way to open a file with Detach from central and Ignore the fact, that central model is unavailable?
I'm using the following code. In the OpenOptions there is no suitable property.
// open the document OpenOptions options = new OpenOptions() { AllowOpeningLocalByWrongUser = true, Audit = false, DetachFromCentralOption = DetachFromCentralOption.DetachAndDiscardWorksets }; Application app = sender as Application; // However, UIApplication can be // instantiated from Application. UIApplication uiapp = new UIApplication(app); var filePath = @"d:\1.rvt"; var modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath); try { uiapp.OpenAndActivateDocument( modelPath, options, true); } catch (Exception ex) { Debug.WriteLine(ex.Message); }
Thanks,
Victor.