Copy whole document

Hi,

I have 2 GoGraphic documents in my application. Document 2 is opened when you double click a node in document 1, then user draws few nodes and links in document2.
Document 2 is effectively belongs to a node in document1.
When even user copy and paste the node in document1 my application i have to create copy of node in document1 and copy of document2 (all the nodes and links etc.) as another document (document3) automatically.
N.B: one node can have multiple associated documents.
Can you suggest me some ideas for doing it.

You could just open multiple views on the same document, and move the objects you want to see in View2 into a separate layer. Views can choose which layers are visible.



See the Object Browser sample.

Hi,



Multiple views in same document is not going to help for my application.



I was thinking create GoObjects array and copy all objects using Document.CopyTo.



Then create another document and use Document.CopyFromCollection function to paste all the objects.



Do you think my idea works or not.

You can just create a GoCollection and .Add the objects you want to it, then do the CopyFromCollection into the second document.



for example:



goView2.Document.CopyFromCollection(goView1.Document);



will make a copy of the first view’s document into the second one.



A wise old programmer taught me a long time ago… “any time you have two copies of something, one of them is eventually going to be wrong”.



I don’t envy you the task of keeping “one node in multiple documents” in sync.

Hi,

<p style=“margin: 0cm 1.5pt 0.75pt; line-height: normal;” =“Msonormal”>If I use this method to create a copy of an
document. How can I preserve the GoLink attachments on the ports in the New
copied document?<?: prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>

goView2.Document.<span =“highlight”>CopyFromCollection(goView1.Document);

That’s weird, I thought I had answered this.

<span =“Apple-style-span” style=": rgb248, 248, 252; “><span =“highlight”=”">CopyFromCollection will copy all the links and their connections to nodes.

I will have to dig deeper all my nodes and links is copied but the links is not attached to the ports. Any pointers? Except for the lose go links the copy is perfect.

Serialization issue?

The first thing to try is a call to GoDocument:TestSerialization() to check. (See the API reference).