Disable Diagram.grid zoom

Hello!

What is the correct way to disable zoom for Diagram.grid ?
I’ve tried to set diagram.grid.scale on ViewportBounds Changed diagram event, but that doesn’t make any effect.

Thanks
Vlad.

When I set GraphObject.scale on the “Grid” Panel that is the value of Diagram.grid, it is drawn with spacing twice as big as normal. So it definitely has an effect. Perhaps you want some other behavior?

Basically I want to grid remain same scale while zooming a model

So you want nodes and links to shift relative to the grid as the user zooms in or out. OK. But when I try this, it seems to work well:

myDiagram.addDiagramListener("ViewportBoundsChanged", e => {
  const sc = e.diagram.scale;
  if (e.subject.scale !== sc) {
    e.diagram.grid.gridCellSize = new go.Size(10/sc, 10/sc);
    // assuming the Shapes of the default grid:
    e.diagram.grid.elt(0).strokeWidth = 0.5/sc;
    e.diagram.grid.elt(1).strokeWidth = 0.5/sc;
    e.diagram.grid.elt(2).strokeWidth = 1/sc;
    e.diagram.grid.elt(3).strokeWidth = 0.5/sc;
    e.diagram.grid.elt(4).strokeWidth = 0.5/sc;
    e.diagram.grid.elt(5).strokeWidth = 1/sc;
  }
});

Of course you should substitute your actual grid cell size for the hard-coded 10s that I have in my example code.