Copy and paste - clipboard

Hi, I wanna know how can I identify the object I copied when I paste.
I have a database and I need to copy the record of the object I copied, I identify the record by the partId. So I need to know the ols partId and the new one. is it possible?

Thanks in advance,
Pablo Becker.

In CopyObject, the object returned from base.CopyObject is the “new copy” and the “this” is the object being copied. (See samples in Flowgrammer, OrgCharter, Processor.)
for example, here is the code from GraphNode.cs in OrgCharter…

public override GoObject CopyObject(GoCopyDictionary env) {
GraphNode newobj = (GraphNode)base.CopyObject(env);
if (newobj != null) {
newobj.UserObject = new GraphNodeInfo(newobj);
}
return newobj;
}

Thanks it works great!

I just have a problem with the undo.
I copied and pasted an object. When I undo, on the “documentChanged” “case GoLayer.RemovedObject:” the partID is -1.
How can I know the real partID?

Thanks in advance,
Pablo.

And you have Document.MaintainsPartID = true?

Yes.
The problem is that the partID is asigned after inserted. When I delete an obejct I have the partID on GoLayer.RemovedObject, but I dont have the partID when I do undo after paste (it execute the GoLayer.RemovedObject)

here’s the trace of DocumentChanged events for the Paste:

Doc.StartTrans
Layer.InsertedObject ID = -1
Layer.ChangedObject ID = 2 (GoNode.ChangedPartID oldID=-1)
Layer.ChangedObject
Doc.EndTrans

and the trace for undo:
Doc.StartingUndo
Layer.ChangedObject
Layer.ChangedObject ID = -1 (subhint: GoNode.ChangedPartID oldID=2)
Layer.RemovedObject ID = -1
Doc.FinishedUndo