I hope that the links path is just not affected by some nodes

I created a node(printBox) and set the value of avoidable to false.
The routing property of the link is go.Link.AvoidsNodes.

First,

Then,I add a node(printBox) on myDiagram

I hope that the links path is just not affected by printBox.What should I do?

     myDiagram.nodeTemplateMap.add("printBox",
	 g_(go.Node, "Viewbox",{
		 rotatable: true,
		 locationSpot: go.Spot.Center,
		 locationObjectName: "SHAPE",
		 selectionObjectName: "SHAPE",
		 avoidable: false,
		 isLayoutPositioned:false,
		 // don't re-layout when node changes size
		 layoutConditions: go.Part.LayoutStandard & ~go.Part.LayoutNodeSized,
		 background: null
		 }, 
		new go.Binding("location","loc",go.Point.parse).makeTwoWay(go.Point.stringify), 
		g_(go.Panel, "Spot", g_(go.Shape, "Rectangle", {
			 name: "SHAPE",
			 stroke: "rgba(255,0,0,1)",
			 strokeWidth: 10,
			fill: "rgba(0,0,0,0)",
			 scale: 1
			},new go.Binding("zOrder"),
			new go.Binding("stroke","color").makeTwoWay(),
			new go.Binding("strokeWidth","thickness").makeTwoWay(),
			new go.Binding("desiredSize","desiredSize",go.Size.parse).makeTwoWay(go.Size.stringify)),
			g_(go.TextBlock, { 
				text: "page number", 
				stroke:"rgba(255,0,0,1)",
				font: "bold 20pt serif",
				alignment: new go.Spot(1,1,-30,-30),
				editable: true, isMultiline: false
			 },
			new go.Binding("text","text").makeTwoWay()))));

I think you did the right thing – you set Node.avoidable to false. So I cannot explain the behavior that you are seeing. Perhaps there are other changes happening at the time that you are adding that “printBox”?

Another possibility is to change that “printBox” from Node to simple Part.

By the way, you don’t need to set Node.layoutConditions when you have already set Node.isLayoutPositioned to false.

Thank you!
But there are not other changes happening at the time that I am adding the “printBox” .
When I change the “printBox” from Node to simple Part.Part doesn’t have avoidable property.
it is surprising that the problem was solved.
Why?

I just added your template to a copy of the Dynamic Ports sample (which uses AvoidsNodes routing Links), and added this function:

  function addPrintBox() {
    myDiagram.commit(d => {
      d.model.addNodeData({
        category: "printBox",
        color: "red",
        thickness: 3,
        loc: "200 200",
        desiredSize: "500 500",
        text: "test"
      });
    }, "added printBox");
  }

When I call that function, a “printBox” does get added, but it does not cause any of the links to be rerouted.

            "draggingTool.dragsLink": true,
            "draggingTool.dragsTree": true,
            "linkingTool.direction": go.LinkingTool.ForwardsOnly,
            "linkingTool.isUnconnectedLinkValid": false,
            "linkingTool.portGravity": 20,
            "relinkingTool.isUnconnectedLinkValid": true,
            "relinkingTool.portGravity": 20,
            "relinkingTool.fromHandleArchetype": g_(go.Shape, "Diamond", {
                segmentIndex: 0,
                cursor: "pointer",
                desiredSize: new go.Size(8,8),
                fill: "tomato",
                stroke: "darkred"
            }),
            "relinkingTool.toHandleArchetype": g_(go.Shape, "Diamond", {
                segmentIndex: -1,
                cursor: "pointer",
                desiredSize: new go.Size(8,8),
                fill: "darkred",
                stroke: "tomato"
            }),
            "linkReshapingTool.handleArchetype": g_(go.Shape, "Diamond", {
                desiredSize: new go.Size(7,7),
                fill: "lightblue",
                stroke: "deepskyblue"
            }),
            "undoManager.isEnabled": true,
            "ChangedSelection":inspectorHide,
            allowDrop: true,
            allowLink: false,
            "animationManager.isEnabled": false,
            mouseDrop: function(e) {
                finishDrop(e, null);
            },
            "linkingTool.insertLink": function(fromnode, fromport, tonode, toport){
                myDiagram.model.setCategoryForLinkData(this.archetypeLinkData, SD.itemType);
                return go.LinkingTool.prototype.insertLink.call(this, fromnode, fromport, tonode, toport);
            },
            "clickCreatingTool.archetypeNodeData": {},
            "clickCreatingTool.isDoubleClick": false,
            "clickCreatingTool.canStart": function() {
                return SD.mode === "node" && go.ClickCreatingTool.prototype.canStart.call(this);
            },
            "clickCreatingTool.insertPart": function(loc) {
                SD.nodeCounter[SD.itemType] += 1;
                var newNodeId = SD.itemType + SD.nodeCounter[SD.itemType];
                this.archetypeNodeData = {
                    id: newNodeId,
                    category: SD.itemType,
                    label: newNodeId
                };
                return go.ClickCreatingTool.prototype.insertPart.call(this, loc);
            }
        });

Will the setting of these links have an effect?
I find that the Dynamic Ports sample used the CustomLink, and it does work. It’s magical,Why?

I would not think that any of those tool customizations would have any affect on what happens when the program executes the addPrintBox function that I defined above.

There are my linkTemplate:

      myDiagram.linkTemplateMap.add("avoidsNodes", 
        g_(go.Link, {
            selectionAdorned: true,
            toShortLength: 0,
            toEndSegmentLength:10, 
	        fromEndSegmentLength:10,
            routing: go.Link.AvoidsNodes,
            corner: 0,
            curve: go.Link.JumpOver,
            fromSpot:go.Spot.RightSide, 
            reshapable: true,
            resegmentable: true,
            relinkableFrom: true,
            relinkableTo: true
        }, 
        new go.Binding("points").makeTwoWay(),
        new go.Binding("fromSpot", "fromSpot", go.Spot.parse),
        g_(go.Shape, {
            stroke: "rgba(0,0,0,1)",
            strokeWidth: 3,
            strokeDashArray:  [5,2]
        }, 
        new go.Binding("strokeWidth","thickness").makeTwoWay(), 
        new go.Binding("strokeDashArray","dashes"), 
        new go.Binding("stroke","link_color")), 
        g_(go.TextBlock, {
            editable: true,
            _isNodeLabel: true,
            alignment: new go.Spot(0.5,1,5,10),
            font: "bold 8pt helvetica, bold arial, sans-serif",
            cursor: "pointer"
        }, 
        new go.Binding("segmentOffset", "segmentOffset", go.Point.parse).makeTwoWay(go.Point.stringify),
        new go.Binding("font","font"), 
        new go.Binding("stroke","text_color"), 
        new go.Binding("text","text").makeTwoWay())
        ));

if I set the go.Link to CustomLink,return on Investment.


So,why?

Even after using all of your code to initialize the Diagram and the link template, I am still unable to reproduce any problem.

I copied your code verbatim, but I did replace “g_” with “$” and I did comment out code that depended on external definitions that you did not include in your code.

Because I used your code, I did not use CustomLink at all.