Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

7 REPLIES 7
Reply
Message 1 of 8
DMadhuri
4558 Views, 7 Replies

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

Hi,

 

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

Thanks

 

 

7 REPLIES 7
Message 2 of 8
jeremytammik
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

Application.GetRevitServerNetworkHosts()
Application.CurrentRevitServerAccelerator
Document.WorksharingCentralFilename

replace the properties

Application.CentralServerName
Application.LocalServerName
Document.GetWorksharingCentralModelPath()

The new members:

Application.GetWorksharingCentralGUID(ServerPath serverModelPath)
Document.WorksharingCentralGUID

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
--
Jeremy Tammik
Autodesk Developer Network -- http://www.autodesk.com/joinadn
The Building Coder -- http://thebuildingcoder.typepad.com



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

Message 3 of 8
DMadhuri
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);  
doc_1.SaveAs("Newfile1.rvt");

 

but this still links to the central file.

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

 

Thanks

Message 4 of 8
david.rock
in reply to: DMadhuri

Hello,

 

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?

 

Regards

David

 

Message 5 of 8
DMadhuri
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..

 

 

Message 6 of 8
b_ralphs
in reply to: DMadhuri

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

Message 7 of 8
AnatolyCEL
in reply to: b_ralphs

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

 

Thanks,

Anatoly.

Message 8 of 8

To check if a model is Central the following method can be used.

 

if (Autodesk.Revit.DB.BasicFileInfo.Extract(doc).IsCentral)
{

}

 

 

For central model which are copied to a different location (when normally you get the above message) the above value returns true.

central model is copied.jpg

 

To you also check central models which have been accidentally moved, I found that the condition below have the desirable result. This always finds the local and the central model and if those two parameter are equal, it means that you are working in a central model.

 

 

if (Autodesk.Revit.DB.BasicFileInfo.Extract(doc_wea.PathName).CentralPath != doc_wea.PathName)

{



}

 

 

I hope this is helpful to others.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community