Show dimesion of object

How to show dimension of object/node similar to the wall parts as shown in image

Take a look at the “Gamma” node in Using Dimensioning Links.

Or you could customize the Part.selectionAdornmentTemplate to show the dimensions. See Show dimension to dragged object in floor planner

$(go.Adornment, “Spot”,
$(go.Panel, “Auto”,
//$(go.Shape, { stroke: “dodgerblue”, strokeWidth: 2, fill: null }),
$(go.Placeholder, { margin: 2 })
// Assume the SHAPE’s desiredSize is stored in data.size as a string by the TwoWay Binding on SHAPE
$(go.TextBlock, { stroke: “dodgerblue”, alignment: go.Spot.Top, alignmentFocus: new go.Spot(0, 1, 3, 0) },
new go.Binding(“text”, “width”, function(s) { return convertPixelsToUnits(s);})),
$(go.TextBlock, { stroke: “dodgerblue”, alignment: go.Spot.Left, alignmentFocus: new go.Spot(1, 0, 0, 3) },
new go.Binding(“text”, “height”, function(s) { return convertPixelsToUnits(s);}))

Hi walter ,
it worked for me but when i am using “convertPixelsToUnits” function to show value in selected units to does not show any values.

Floorplan.prototype.convertPixelsToUnits = function (num) {
var units = this.model.modelData.units;
if (units === ‘meters’) return (num / 100) * 0.5;
if (units === ‘feet’) return (num / 30.48) * 0.5;
if (units === ‘inches’) return (num / 2.54) * 0.5;
return num * 0.5;

although function is getting called but no value is displyed.

What are the value of data.width and data.height for that node?

width: 106.68,
height: 182.88,

OK, and what’s the value of this.model.modelData.units as you are stepping through that code?


The value of TextBlock.text must be a string, not a number. So convertPixelsToUnits must return a string.

If you are using go-debug.js you might get a warning about that.

Binding error: ReferenceError: convertPixelsToUnits is not defined setting target property “text” on TextBlock("") with conversion function: function (s) { return convertPixelsToUnits(s);}

i am getting this in console even though convertPixelsToUnits returns string.

That error seems to be accurate – you need to fix your JavaScript code to refer to your conversion function properly.

Thanks Walter.