Connect to subgraph programmaticaly

I created a GoSubgraph with multiports (top & bottom) and tried to connect programmatically one GoTextNode to the the top port of the subgraph and other GoTextNode to the bottom port of the subgraph. The problem is that the links shows up as well as the nodes and the subgraph but the links are not connected to the subgraph ports even though i explicitly set the correct ports (subgraph’s ports). what is it that i’m doing wrong?
if i try to connect the nodes to the subgraph in design mode (not programmatically) then it works fine.


With the help of Jake i found that the problem was with the GoDocument.AddCopy function which doesn’t work correctly with GoSubgraph object. Simply create the GoSubgraph explicitly and add it to the GoDocument. then you’ll be able to programmatically connect it to other nodes in the diagram.

This was a problem in Adi’s subclass of GoSubGraph. If you add fields to your class, you typically have to override CopyChildren to initialize the fields to get AddCopy to work correctly.