this.patcher.box and bpatchers

I am attempting to create a JS, that when used will discover the absolute position of an named object, regardless of whether its in a batcher, a few bpatchers, or in the parent itself.

In the javascript in max pdf, the thispather.box property is used to return the parent patcher. However, I get errors trying to reference this.patcher.box from within a bpatcher. Does this only work within subpatchers?

A workaround ive found is to use this.patcher.parentpatcher,which seems to resolve parent bpatchers properly. However, it stops once it reaches the patch that contains the bpatcher, (ie, only one level above), and will not iterate to any other parent patchers.

The following code works properly when called from either the main patch, or the parent patch, but no futher above the patcher heirarchy.

I am obviously misunderstanding something. Id love a pointer in the right direction.

function locate(name)
{
obj = this.patcher.getnamed(name);

objCoords= obj.rect; // get the cordinates from within the objects patch

Hi Vade,
I’ve attached a zip file with a JS, 2 bpatchers, and a main patch.
One of the bpatchers has a nested bpatcher as well. The patch shows
how to get absolute coordinates of max objects in batchers. This is
all using the maxobject.rect property. Hopefully the attachment gets
posted. If not, I’ll repost it tommorrow when I can get my computer
back online.

On the matter of ‘having to find the parent window to get global
coordinates’. I think this patch pretty clearly demonstrates that
this is not the case. I never get the coordinates of the windows and
am perfectly capable of getting the location of a double nested object
(located in a bpatcher in a bpatcher) with the rect property. Now, if
you want to know where it is in screen coordinates, you will have to
get the x, y location of the main window, but *only* the main window.
This is not such a big deal as it is trivial to access the main window
that the JS object is located in.