Add Link Adornments to the node

Can you help me with the function that add length adornment (double arrow headed link) to the node as in Wall in WallParts Palette in FloorPlanner?
I tried finding the script that contains this function but couldn’t.

I only want to show dimensions when it is selected!

On your node template you could set Part | GoJS API to a function that adds a DimensioningLink when the node isSelected, and removes it when the node is no longer selected.

You have a choice to add such a link to the model or not. I suspect you do not want those dimensioning links in the model, so you should construct each DimensioningLink in your event handler when selected and directly call Diagram.add, and later call Diagram.remove when deselected.