Sorry, I completely misunderstood your situation and what you are trying to do.
The ClickCreatingTool.archetypeNodeData object is copied and the copy is added to the model. But copying an individual node data object or link data object will not copy any unresolved relationships – so no nodedata.group
property value nor any linkdata.from
or linkdata.to
property value. The copying code is responsible for resolving any relationships. There are many reasonable policies that can be implemented regarding relationships with parts. For example, in your case, the reference to the group could be resolved in the target model, as I think you are expecting. But it could instead be resolved to nothing, as actually happens, leaving it as a top-level part. Or it could be resolved to some existing group, or one that is newly created for it. And even relationships between parts in a copied collection can be modified too – for example there might be only one instance of a particular object allowed in a model. Various apps can have different requirements than what you might expect.
Anyway, the normal way to implement what you want is in a “PartCreated” DiagramEvent listener. Just add the e.subject
to be a member of the Group that you want.
$(go.Diagram, "myDiagramDiv",
{
"clickCreatingTool.archetypeNodeData": { text: "M", color: "yellow" },
"PartCreated": function(e) {
e.subject.containingGroup = e.diagram.findNodeForKey(5)
},