June 9, 2020

Worksharing model support by Revit Design Automation

Follow @JohnOnSoftware

Opening a Revit worksharing model on Revit Design Automation engine is a frequently asked question, and this is not supported directly by Revit Design Automation engine before, you need to handle it with a little bit of extra code, there is a discussion on StackOverflow talking about bypassing the dialog box “Model has been transmitted from remote location”. Now comes the good news, it's supported out of box by Revit Design Automation, please check the change log HERE

Improved the default behavior for opening and saving models that have worksharing enabled, in order to preserve worksets on open, and support saving the model as a new central.

While the Revit Design Automation engine allows opening of workshared model, the file is opened in DA as detached from central with the worksets being preserved (detach-and-preserve-workset option). This means that while saving the file, you will need to use the worksharing settings to save the new file as central, here is sample code to demo how to save the workshared model:


ModelPath path = ModelPathUtils.ConvertUserVisiblePathToModelPath("result.rvt");
// If a worshared file is opened as a part of this addin then the new file will be 
// saved as central.
SaveAsOptions opts = new SaveAsOptions();
if (doc.IsWorkshared)
{
    opts.SetWorksharingOptions(new WorksharingSaveAsOptions { SaveAsCentral = true });
    WorksharingUtils.RelinquishOwnership(doc, new RelinquishOptions(true), new TransactWithCentralOptions());
}
doc.SaveAs(path, new SaveAsOptions());

For details, you can also check the DeleteElementsApp sample.

Good luck with Forge ;)  

Posted by

Developer Advocate

Zhong Wu started his career in Autodesk since 2006 on AutoCAD Architecture as a software developer with more than 6 years working experience. After that, Zhong moved to Autodesk Development Network(now is renamed to Forge Partner Development) team as a Developer Advocate mainly focus on the API support/consultant for Maya/MotionBuilder, and started to contribute in Forge evangelism and support with the growing of...

Related Posts