Request: option to make Layout snap to Grid

Just requesting if it’s possible get an option to turn on Grid Snapping for Layout(s). I have the following work around. It works but it’s a bit finicky. And one of my node templates had some offset thing happening which I couldn’t work out how to calculate properly so I hard coded it.

var GRID_SIZE = 25;<br />CustomLayout.prototype.doLayout = function(coll) {<br />,coll);<br /> for (it = coll.nodes.iterator;; ) {<br /> var n = it.value; // Get the node<br /> var pos = n.position;<br /> var offset = 0;<br /> if (n.category == "topPorts") {<br /> offset = 11.75;<br /> } else if (n.category == "") {<br /> offset = GRID_SIZE;<br /> }<br /> n.position = new go.Point(Math.round(Math.round(pos.x / GRID_SIZE) * GRID_SIZE) + offset,Math.round(Math.round(pos.y / GRID_SIZE) * GRID_SIZE) );<br /> }<br />}<br />


In version 1.3 I think you could do:
diagram.moveParts(diagram.nodes, new go.Point(), false)
assuming DraggingTool.isGridSnapEnabled is true and that you do not need to maintain any custom link routing performed by tne layout.
This might even work in version 1.2, undocumented.

Also in version 1.3 there will be new methods: Point.snapToGrid or snapToGridPoint.