Create/Open Local Copy

Create/Open Local Copy

Anonymous
Not applicable
1,978 Views
6 Replies
Message 1 of 7

Create/Open Local Copy

Anonymous
Not applicable

I'm accessing a central file and I need to create/open a local copy. But I cant file anything in the API to accomplish this. Or I need to be able to relinquish from the central. How is this done, thanks.

0 Likes
1,979 Views
6 Replies
Replies (6)
Message 2 of 7

jeremytammik
Autodesk
Autodesk

Dear bthatcher,

 

Look at the What's New section of the Revit API help file RevitAPI.chm:


New overloads for Application.OpenDocumentFile() and UIApplication.OpenAndActivateDocument()

The new overloads support parameters OpenOptions and OpenOptionsForUI, respectively, to specify how a Revit document should be opened. Both options classes currently offer the ability to detach the opened document from central if applicable.

The property:

  • OpenOptions.DetachFromCentralOption
    can be set to DoNotDetach (the default) or DetachAndPreserve.

The property:

  • OpenOptionsForUI.DetachFromCentralOption
    can be set to DoNotDetach (the default), DetachAndPreserveWorksets or DetachAndPrompt.

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

0 Likes
Message 3 of 7

Anonymous
Not applicable

I believe I have gone through all of those options. To be sure, I set up a dialog to test them. Using 'OpenDocumentFile' it's not clear what the name of the document is, so I've collected them and listed them in a listbox. Even doing it manually, the only way is to detach and preserve worksets, save as, then reopen with the 'Create New Local' checked. Every option returns the central file name. What am I missing. As always, thanks for your help!

0 Likes
Message 4 of 7

Anonymous
Not applicable

Here is the code I would expect to work 

 

            OpenOptions openOption = new OpenOptions();
            openOption.DetachFromCentralOption = DetachFromCentralOption.DoNotDetach;

            ModelPath modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(targetFile);
            Document openFile = uiApp.Application.OpenDocumentFile(modelPath, openOption);

 

0 Likes
Message 5 of 7

andre_adc-dao
Advocate
Advocate

Hi, you have to create the local copy with the CreateNewLocal method. See this link for more information:https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/Revit-API/files/GUID-...

 

And you open the local copy created (localPath instead of ModelPath in your code sample.

 

Hope this help, even if this post is very old I think it can help other user.

 

Regards,

André

Message 6 of 7

paolomod3nese
Enthusiast
Enthusiast

Exactly what i was looking for!

 

The link you posted seems to be dead, here's a live one of the CreateNewLocal method:

https://www.revitapidocs.com/2020/90102c11-d982-77f5-d08c-e68b1a882281.htm

 

Thank you!

Message 7 of 7

andre_adc-dao
Advocate
Advocate

Thank you for the updated link!

0 Likes