Forums > MaxMSP

Get location of object

May 3, 2008 | 3:58 pm

Hi, i’m trying to create a patch which can replace bpatchers in exactly the same position, so the interface can change dynamically. I’m trying to write an abstraction so i can do this for any object. The issue i’m having is getting the position of the original bpatcher so i can replace it with a new bpatcher in exactly the same position using scripting. Is it possible to get the position from this (or any) type of object?

my idea for the scripting process is ‘get position of bpatcher1, delete bpatcher1, create new bpatcher2 in bpatcher1′s place’.



May 4, 2008 | 12:44 pm

Hi, i got it working (sortof), from here (horvathzsolt[AT]hotmail.).

The only issue is it returns the wrong size. Has there been any known changes to the format of location messages or the attribute patching_rect in max 5?



May 4, 2008 | 1:32 pm

have a look at the patchdescribe script in the examples/javascript





function bang()

function iterfun(b)
if(b.maxclass == "bpatcher"){
outlet(0, b.varname, b.rect);
return true;

– Pasted Max Patch, click to expand. –

May 4, 2008 | 4:36 pm

I’ve been looking at that but it seems that the position that reports is still wrong, the first two numbers are correct, the last two aren’t. Is it just my install (updated to atleast build of 5 today) or a known bug/issue?


May 4, 2008 | 6:28 pm

works for me:
the numbers represent the left, top, right and bottom edges of the box
as measured from the top left corner of the patcher.

in the max5-bpatcher inspector you get different numbers representing
left, top (box-position) then width, height.

do the math:
right – left = width;
bottom – top = height;

what numbers do you want to plug into the replacement script?


May 4, 2008 | 6:40 pm

Hi, thanks for all the help.

I’m lookign for the same for the same values as max-5′s inspector (left,top,width,height).

i’ll try some maths stuff on the output of my js.


Viewing 6 posts - 1 through 6 (of 6 total)