I have a 20x20 grid and Orthogonal routing with nodes having fromSpot/toSpot as AllSides.
To align links with grid I’ve created a custom Link class which overrides computePoints to align points with grid. It works as expected and all links follow grid:
The problem with “…Side” Spots is that as the number of links connecting on a particular side changes, the standard link connection point computation will spread them out evenly on that side, causing them no longer to be aligned according to any fixed grid. Perhaps you have avoided that problem in your custom computePoints method, but it gets pretty complicated.
Furthermore I notice that your nodes don’t seem to have all sides aligned to your grid, which complicates things even more.
I don’t have an easy answer for AvoidsNodes routing. Which version of GoJS are you using?
I use 3.0.27 at the moment. I see now that 3.1 had some improvements to links routing and AvoidsNodes, I’ll give it a try tomorrow.
For the node sides I was able to account for that in my custom computePoints — if point is on the node size, I only snap 1 coordinate so the port is still on the node edge.
Is it possible to extend AvoidsNodes router somehow?
One possibility is to change the grid that the AvoidsNodesRouter uses in v3.1. But I haven’t tried it for this specific purpose.
Yes, it might be possible to override methods on the AvoidsNodesRouter class even though it isn’t public. You can get an instance of it as the first element in the Diagram.routers list.