findNodesByExample has no effect on go.Part

I want to search all the “PRINTBOX” in the drawing,So I used findNodesByExample :

   myDiagram.nodeTemplateMap.add("PRINTBOX",
              g_(go.Part, "Viewbox",......)
   myDiagram.findNodesByExample({ category: "PRINTBOX" });

However, this method does not support go.Part.

That’s true, it was designed to only work for Nodes, and Diagram.findLinksByExample only for Links.

Maybe you want to do something like this:

myDiagram.model.nodeDataArray
    .filter(function(d) { return d.category === "PRINTBOX"; })
    .map(function(d) { return myDiagram.findPartForData(d); })

@walter I have tried for the node part as well it’s not showing the changes
I dont know where i m doing this wrong… beta node is not toggled!
myDiagram.nodeTemplateMap.add(“Pen”,
$(go.Node,“Auto”, // the Shape will go around the TextBlock
$(go.Shape,
“RoundedRectangle”,
{ strokeWidth: 0 },
// Shape.fill is bound to Node.data.color
new go.Binding(“fill”, “color”)
),
$(go.TextBlock,
{ margin: 8 }, // some room around the text
// TextBlock.text is bound to Node.data.key
new go.Binding(“text”, “key”)
)
));

/......./
document.getElementById("beta").addEventListener("change", function(e) {
  var alpha = myDiagram.findNodesByExample({category:"Pen"});
  myDiagram.startTransaction("toggle visibility");
  alpha.visible = e.target.checked;
  myDiagram.commitTransaction("toggle visibility");
});

findNodesByExample always returns a collection of Nodes, not a single Node.
https://gojs.net/latest/intro/collections.html#MoreIterationExamples

function(e) {
  myDiagram.commit(function(d) {
      d.findNodesByExample({ category: "Pen" })
          .each(function(n) { n.visible = e.target.checked; });
    }, "toggled visibility of Pens");
}