Revit API

Active Contributor
Posts: 40
Registered: ‎07-27-2011
Message 1 of 7 (933 Views)

How to Check If Model is Attached/Detached from Central ??

933 Views, 6 Replies
03-22-2012 12:37 AM



I am working with the Revit API that requires  deleting some elements from the Revit Model and need some help in knowing couple of things before deleting them.

I want to delete the elements only if the model is detached from the central or is not a Working_local copy  as I dont not want the model to be synchronized with central at any later point .

I'm sucessful in getting the required elements and also in deleting them.

Came across some of the API Methods like Save and SaveAs but they do not provide an option to make the Saved model as a central/ Detahc and save.Let me know if this is really possible to detect if model is still connected to Central or is Detached.


Does API has any such methods available?? or any possible workarounds


Any help is really appreaiated




ADN Support Specialist
Posts: 493
Registered: ‎08-20-2007
Message 2 of 7 (838 Views)

Re: How to Check If Model is Attached/Detached from Central ??

05-08-2012 02:23 AM in reply to: DMadhuri

Dear DMadhuri,

Maybe some of the worksharing properties can help you?

Here is an excerpt from the Revit 2013 API What's New section:

Worksharing properties

The information required to identify a workshared file on the central or local locations have changed due to changes to RevitServer. As a result, the members


replace the properties


The new members:

Application.GetWorksharingCentralGUID(ServerPath serverModelPath)

provides read access to the worksharing central GUID of the given server-based model. This is applicable only to workshared models saved in Revit 2013 or later.

Best regards,

Jeremy Tammik
Autodesk Developer Network --
The Building Coder --

Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Active Contributor
Posts: 40
Registered: ‎07-27-2011
Message 3 of 7 (806 Views)

Re: How to Check If Model is Attached/Detached from Central ??

05-21-2012 04:07 AM in reply to: jeremytammik

Hi Jeremey,


Thanks for the reply, I am able to extract the details of WorksharecentralPath, PathName,.. etc of the model.

However, I tried looking into another way of  trying to Detach the model and save as a new central file as below:


ModelPath mpath=  ModelPathUtils.ConvertUserVisiblePathToModelPath(doc.PathName); 

OpenOptions open_Opts = new OpenOptions();                         open_Opts.DetachFromCentralOption=DetachFromCentralOption.DetachAndPreserveWorksets;
 Document new_Doc = app.OpenDocumentFile(mpath, open_Opts);  


but this still links to the central file.

Any ideas on detaching the file from central would be appreciated.



Posts: 11
Registered: ‎04-02-2003
Message 4 of 7 (780 Views)

Re: How to Check If Model is Attached/Detached from Central ??

06-08-2012 01:39 AM in reply to: DMadhuri



I'm looking for the new method of obtaining the full path of the central file name.


Since Document.WorksharingCentralFilename is now obsolete I tried to use GetWorksharingCentralModelPath but it is not giving me a value.


Any ideas?





Active Contributor
Posts: 40
Registered: ‎07-27-2011
Message 5 of 7 (772 Views)

Re: How to Check If Model is Attached/Detached from Central ??

06-10-2012 05:06 AM in reply to: david.rock

Hello David,

You can try this:

ModelPath mpath= Document.GetWorksharingCentralModelPath() works if the models is saved. ans returns a ModelPath

mpath.CentralServerPath should be the value you are after.

Hope this helps..



Valued Contributor
Posts: 65
Registered: ‎11-15-2006
Message 6 of 7 (534 Views)

Re: How to Check If Model is Attached/Detached from Central ??

05-02-2013 11:48 AM in reply to: DMadhuri

Since GetWorksharingCentralModelPath() only works on saved models, how do I get the central path for a just opened/unsaved model?

Posts: 5
Registered: ‎08-12-2013
Message 7 of 7 (373 Views)

Re: How to Check If Model is Attached/Detached from Central ??

09-16-2013 11:38 AM in reply to: barry

I have similar problem: I need check if opening file in Revit is detached from central, i.e. With API, in DocumentOpening event, how to check if user cheked or not "Detach from Central" option. I have tried to handle "DialogBoxShowing" event to catch TaskDialog_Detach_Model_From_Central dialog box, but it doesn't work always




Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.