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
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
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
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
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..
Since GetWorksharingCentralModelPath() only works on saved models, how do I get the central path for a just opened/unsaved model?
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.
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.
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.