GraphObject getDocumentPoint throws error

Hi GoJS Team,

I want to retrieve all TextNode and its view port location so I have function as below to get all textnode objects.

var objs = [];
var wrapObjects = dia.findObjectsIn(rect, function(o) {
if (o instanceof go.TextBlock) objs.push(o);
console.log(“Name”, o.name);
return o.name === “messageWrapShape”;
}, function(o) {
return console.log(o);
}, true);

then want to call transformDocToView to get point i m interested on but when trying to call objs[0].getDocumentPoint() for each object, I got below error – please, help.

go.js:103 Uncaught TypeError: Cannot read property ‘x’ of undefined
at z.set.z.set (go.js:103)
at Lh.G.getDocumentPoint.G.Wa (go.js:1019)
at :1:5

Do you know what console.log(o) evaluates to?

It returns false

No, it returns undefined, which explains the error message.

No It is not undefined; You can confirm from this snapshot.

Actually console.log("aha") === undefined will return true. However that acts like a false value in these circumstances.

The problem is in the first function – it’s returning true or false when it needs to return a GraphObject or null:

Hi Walter,

It gives all graphical objects but It when calling getDocumentPoint() – It throws exception as mention earlier.

However, actualBoudns api worked as below for first object.
objs[0].actualBounds
B {x: 0, y: 3.1783203124999995, width: 32.62890625, height: 9.643359375000001}

I want to convert points into view port with function : transformDocToView so, I need documentPoint for first object but It always throws exception; please guide.

If you look at the documentation, GraphObject | GoJS API, you will see that it requires an argument that either is a point in local coordinates or is a spot on that object that determines the point in local coordinates to be transformed.