Forums > MaxMSP

Get location of object


ctb
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’.

Thanks

Lou



ctb
May 4, 2008 | 12:44 pm

Hi, i got it working (sortof), from here http://www.cycling74.com/cgi-bin/searchsite.pl?SearchText=function+getposition1%28objectname%29 (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?

Thanks

Lou


May 4, 2008 | 1:32 pm

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

hth

/*j

————————————————————–

/*
locate_bpatcher.js
*/

function bang()
{
this.patcher.apply(iterfun);
}

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

– Pasted Max Patch, click to expand. –


ctb
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?

Lou


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?

/*j



ctb
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.

Lou


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