Get location of object
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
Hi, i got it working (sortof), from here https://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
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;
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
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
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