I am trying to do the same with no luck I could perform Robot clicks on nodes with some success
In my case, the node to link has a port at the right for the source and left port at the destination node
I used a similar code as you mentioned But I am not sure If i need to use the findAdornment as I am not trying to resize any node just want to link them
function linkNodes() {
var from = myDiagram.findNodeForKey(“Lambda”);
var to = myDiagram.findNodeForKey(“Mu”);
if (!from || !to) return;
var frompt = from.port.getDocumentPoint(go.Spot.Center);
var topt = to.port.getDocumentPoint(go.Spot.Center);
robot.mouseDown(frompt.x, frompt.y, 0);
robot.mouseMove((frompt.x+topt.x)/2, (frompt.y+topt.y)/2, 200);
robot.mouseUp(topt.x, topt.y, 400);
}
mentioned only difference is port is not in the center On UI the cross-hair cursor shows only on the right and left modes Any idea why the linking of nodes does not work with robot methods
In the Robot.html sample, the available area for the user to start drawing a link is only along the edge of the node – the area outside of the TextBlock. So trying to start drawing a new link from within the TextBlock will fail, whether interactively or robotically.
But I don’t know what kind of designs your nodes have.
I can help with details after I check with a developer who implemented It
But If you see the attached screenshot, you can see a new link can be drawn between
en as shown
When I used original code that uses center as port , the code moved the one node over another without linking them
Then I used Right and Left as shown below now this doe snot not do anything
var myDiagram = document.getElementsByClassName('gojs-diagram-div')[0].goDiagram;
var from = myDiagram.findNodeForKey("3988");
var to = myDiagram.findNodeForKey("3989");
var frompt = from.port.getDocumentPoint(go.Spot.Right);
var topt = to.port.getDocumentPoint(go.Spot.Left);
return frompt.x+';'+frompt.y+';'+topt.x+';'+topt.y
From appearances it seems that there’s more than one port per node. You’ll need to call Node.findPort to find the correct port. In this case the “fromPort” will be the port on the right side of the first node, and the “toPort” will be the one on the left side of the second node. Node | GoJS API
That’s different from just using the Node.port, which assumes there’s only one port per node. Node | GoJS API