Unable to get object data on click event in contextMenu

Hi team,
Am trying to use contextMenu in my app for floorplanner, but am unable to get the object data on click event when i click anywhere other then my selected object as in “CASE :2”. It worked perfectly when in click on object itself as in “CASE :1”.
Floor%20Planner1
Floor%20Planner2

My code:

$("ContextMenuButton",
        $(go.TextBlock, "ShowFloor"),
        {
            click: function (e, obj) {

                console.log('here1');
                console.log(obj.part.data.startpoint); 
                console.log('here2');
                FloorplanFilesystem.prototype.loadFloorplan(0,obj);
            }
        },
        new go.Binding("visible", "", function (v, obj) {
            if (obj.part.diagram !== null) {
                return obj.part.diagram.selection.count > 0;
            } return false;
        }).ofObject()
    )

And am getting this error:
“Uncaught TypeError: Cannot read property ‘x’ of undefined
at Object.FloorplanFilesystem.loadFloorplanElevation (FloorplanFilesystem.js:729)”

Any help would be appreciated, thanks.

Yes, that’s because in this context, the ‘obj’ parameter refers to a Panel, and ‘obj.part’ refers to the whole Adornment (the context menu), not your selection. The context menu is not what has data.startpoint, the wall(s) you have selected are.

You could get all the walls you have selected by using e.diagram.findNodesByExample({ category: ‘WallGroup’ }), then do something with them / their data instead.

Thank you @ryanj for your instant reply, i was trying to implement that till now, and it work as you said.
But now i dont know how do i find my current selected wall key from bunch of walls data, because am creating many walls dynamically based on some calculations.Is there any way to get only currently selected wall data only?

Iterate over e.diagram.selection and filter out just the selected walls. Or do what I suggested before, then iterate over the walls and only use those with the “isSelected” property set to true.

Thank you again for your help @ryanj and it work like charm, and i appreciated your efforts and time for the quick help.Thanks.