I’ve been playing with these ideas this morning – this should give you a pretty good starting point.
First, add a call to updateWallDimensions() in Floorplan.js at around line 243, inside the toolManager.draggingTool.doMouseMove override, so that your function looks like
this.toolManager.draggingTool.doMouseMove = function () {
if (this.diagram.lastInput.shift) {
this.isGridSnapEnabled = false;
} else this.isGridSnapEnabled = this.diagram.model.modelData.preferences.gridSnap;
this.diagram.updateWallDimensions();
go.DraggingTool.prototype.doMouseMove.call(this);
}
This will ensure updateWallDimensions() is called when a furniture node is dragged.
Then add some code to updateWallDimensions itself.
- In the selection iteration (starting at around line 458), if the selection member is a furniture node, add all intersecting walls (with the same angle as the furniture node, +/- 180 degrees)
// furniture node / multi purpose node
else {
// get walls touching 'part'
floorplan.findObjectsIn(part.actualBounds,
function(x) { var p = x.part; return (p.category === "WallGroup") ? p : null},
function(w) {
var furnitureAngle = part.rotateObject.angle;
var wallAngle = w.rotateObject.angle;
if (furnitureAngle === wallAngle || Math.abs(furnitureAngle - wallAngle) === 180) {
return true;
}
},
true,
walls
);
}
- In the “walls” iteration (starting around line 493), after the wall.memberParts iteration (but before the wallPartEndpoints.sort call), add the leftmost and rightmost Points of the SHAPE element of all intersecting furniture nodes, projected onto the line segment created by the wall, into the wallPartEndpoints array.
// add points where furniture intersects with wall to wallPartEndpoints
var intersectingFurniture = new go.Set(go.Node);
floorplan.findObjectsIn(wall.actualBounds,
function(x) {
var p = x.part;
if (p instanceof go.Node && p.category === "" || p.category === "MultiPurposeNode" && p !== undefined) {
return p;
}
},
function(n) {
if (n !== undefined) {
return n.isSelected;
} return false;
},
true,
intersectingFurniture
);
intersectingFurniture.each(function(f){
// get two farthest endpoints for furniture
var point1 = f.findObject("SHAPE").getDocumentPoint(go.Spot.Left);
point1.projectOntoLineSegmentPoint(wall.data.startpoint, wall.data.endpoint);
var point2 = f.findObject("SHAPE").getDocumentPoint(go.Spot.Right);
point2.projectOntoLineSegmentPoint(wall.data.startpoint, wall.data.endpoint);
wallPartEndpoints.push(point1);
wallPartEndpoints.push(point2);
});
You can see the entire modified Floorplan.js file here (note that link will expire in 24 hours).
This will give you your desired behavior, though please note the angle of the furniture nodes must be the same as or +/- 180 degrees the angle of the wall(s) it is intersecting, otherwise no dimension links will appear. There may be some cleanup you will have to do to this code, depending on your specific requirements. Implementing what I suggested exactly will give you results like this: