Revit API

Revit API

Reply
Active Contributor
DMadhuri
Posts: 41
Registered: ‎07-27-2011
Message 1 of 7 (1,019 Views)

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

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

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

 

 

ADN Support Specialist
jeremytammik
Posts: 663
Registered: ‎08-20-2007
Message 2 of 7 (924 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

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

Active Contributor
DMadhuri
Posts: 41
Registered: ‎07-27-2011
Message 3 of 7 (892 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);  
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

Contributor
david.rock
Posts: 11
Registered: ‎04-02-2003
Message 4 of 7 (866 Views)

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

06-08-2012 01:39 AM 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

 

Active Contributor
DMadhuri
Posts: 41
Registered: ‎07-27-2011
Message 5 of 7 (858 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
b.ralphs
Posts: 65
Registered: ‎11-15-2006
Message 6 of 7 (620 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?

Member
AnatolyCEL
Posts: 5
Registered: ‎08-12-2013
Message 7 of 7 (459 Views)

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

09-16-2013 11:38 AM 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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.