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: 

Create/Open Local Copy

6 REPLIES 6
Reply
Message 1 of 7
bthatcher
1487 Views, 6 Replies

Create/Open Local Copy

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.

6 REPLIES 6
Message 2 of 7
jeremytammik
in reply to: bthatcher

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

Message 3 of 7
bthatcher
in reply to: jeremytammik

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!

Message 4 of 7
bthatcher
in reply to: bthatcher

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);

 

Message 5 of 7
andre_adc-dao
in reply to: bthatcher

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

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

Thank you for the updated link!

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