Rotate a Background Layer node with HTML btn

I want to rotate a node background layer node, I am able to rotate nodes once they are selected. Since
BackgroundImage is not pickable and selectable i cannot rotate it with myDiagram.commandHandler.rotate(45);


  "BackgroundImage", // Background Image Node





      locationSpot: go.Spot.Center,

      zOrder: 0,

      rotatable: true,

      movable: false,
      layerName: "Background",

      selectable: false,

      pickable: false,


… panel and picture …

Use this:

class RotatingDiagramTool extends go.Tool {
  _rotatingPart = null;
  _rotationPoint = new go.Point(0, 0);  // defaults to origin
  _originalAngle = 0;

  canStart() {
    if (!this.isEnabled) return false;
    var diagram = this.diagram;
    if (diagram === null || !diagram.lastInput.left) return false;
    return diagram.findObjectAt(diagram.lastInput.documentPoint) === null;

  doActivate() {
    this._rotatingPart = this.diagram.findLayer("Background").parts.first();
    this._rotationPoint = this._rotatingPart.location;
    this._originalAngle = this._rotatingPart.angle;
    this._initialAngle = this._rotationPoint.directionPoint(this.diagram.firstInput.documentPoint);
    this.isActive = true;

  doDeactivate() {
    this._rotatingPart = null;
    this.isActive = false;

  doMouseMove() {
    var newang = this._rotationPoint.directionPoint(this.diagram.lastInput.documentPoint);
    this._rotatingPart.angle = newang - this._initialAngle + this._originalAngle;

  doCancel() {
    this._rotatingPart.angle = this._originalAngle;
// end RotatingDiagramTool

Adapt the code in the doActivate method for finding the Part to be rotated. The Kitten Monitor sample puts the background image in a Picture in a Part that is in the “Background” Layer.

Initialize with:

myDiagram.toolManager.mouseMoveTools.insertAt(0, new RotatingDiagramTool());

activating this tool does not allow me to deselect any other node.

Then change doActivate to call Diagram.clearSelection.