Moving GoObject between GoDocuments

I’m in the middle of development, and I cannot test the program, so I hope some one can check if the following code works for moving a number of GoNodes and GoLinks from one GoDocument to another GoDocument.

If it's not right, please correct me, or please tell me a better way to do this except Cutting and Pastting.
///
/// Moves GoNodes between two GoDocuments.
///

/// Go nodes in the fromDoc.
/// From Goducment.
/// To GoDocument.
protected void MoveBetweenDocs(ICollection goNodes, GoDocument fromDoc, GoDocument toDoc)
{
ArrayList links = new ArrayList();
foreach(GoNode oneNode in goNodes)
{
foreach(GoLink oneLink in oneNode.Links)
{
if(!links.Contains(oneLink))
{
links.Add(oneLink);
fromDoc.Remove(oneLink);
}
}
fromDoc.Remove(oneNode);
toDoc.Add(oneNode);
}
foreach(GoLink oneLink in links)
{
toDoc.Add(oneLink);
}
}
You don't need to know the "fromDoc", since presumably all of the nodes and links in your collection already belong to that document.
If you already have the collection of nodes and links in an IGoCollection (such as GoCollection or GoSelection), rather than in an ICollection, it's easiest to do something like:
[code] toDoc.CopyFromCollection(coll);
foreach (GoObject obj in coll) obj.Remove();[/code]

Oh, and if you were trying to figure out what links to move/copy given a collection of only nodes, it is conventional to just include links that connect nodes that are in the collection. It normally doesn’t make sense to move/copy links where only one or neither of the connected nodes are being moved/copied.

GoToolDragging.ComputeEffectiveSelection already does this for you.
[code] GoToolDragging dragtool = (GoToolDragging)goView1.FindMouseTool(typeof(GoToolDragging));
GoSelection extcoll = dragtool.ComputeEffectiveSelection(coll, false);
toDoc.CopyFromCollection(extcoll);
foreach (GoObject obj in extcoll) obj.Remove();[/code]

Thanks. But it’s still not what I wanted.
Your code looks to me is to move a copy of the nodes to a document, but I wanted the original nodes to be moved to another document. For some reason, I cannot copy some of my nodes. Also I need to reposition the nodes by an offset after they are moved.

So I was trying to figure out how to move a group of nodes and links from one document to another one.
If you are having problems with copying, you probably need to fix that for reasons beyond this particular issue.
If you divide your collection of GoObjects into different IGoCollections, one for each GoLayer in the destination GoDocument, then you can call GoLayer.AddCollection for each of those destination layers.