How to create the detached from central while keeping the central document open

How to create the detached from central while keeping the central document open

Anonymous
Not applicable
833 Views
3 Replies
Message 1 of 4

How to create the detached from central while keeping the central document open

Anonymous
Not applicable

Hello there, I've created an app, that creates and save a detached from central document. But it do not allow me to keep the central document open while creating the detached document. Here's my sample code:

 

        public void CreateSaveDetachedFile(Application application, string revitFilePath)
        {

            string detachedfolderpath = @"C:\Users\Ali asad\Desktop\Local Alexa Copy"; 
            string detachedfilename = "";

            //Get information of current opened revit file
            FileInfo filePath = new FileInfo(revitFilePath);
            ModelPath revitCentralFile = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath.FullName);

            OpenOptions openOptions = new OpenOptions();
            openOptions.DetachFromCentralOption = DetachFromCentralOption.DetachAndDiscardWorksets;
            detachedfilename = filePath.Name;

            Document openedDoc = application.OpenDocumentFile(revitCentralFile , openOptions);
           
            SaveAsOptions options = new SaveAsOptions();
            options.OverwriteExistingFile = true;

            ModelPath modelPathout = ModelPathUtils.ConvertUserVisiblePathToModelPath(detachedfolderpath + "\\" + detachedfilename);

            //Save detached document
            openedDoc.SaveAs(modelPathout, options);

            openedDoc.Close(false);

        }

I would appreciate if someone explain, how do I keep the central document open while I create the detached from central document. Thank you.

0 Likes
834 Views
3 Replies
Replies (3)
Message 2 of 4

Mustafa.Salaheldin
Collaborator
Collaborator

What is exactly the error message you got? Can you share a screen shot?


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 3 of 4

Dale.Bartlett
Collaborator
Collaborator

I didn't look too closely, but the SaveAs process will make the current file into the new file. I would not expect the source Central File to also be open. Dale 




______________
Yes, I'm Satoshi.
0 Likes
Message 4 of 4

Mustafa.Salaheldin
Collaborator
Collaborator

Nice. Please if this topic is answered mark the reply as answer.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes