Forums > MaxMSP

bpatcher scripting bug

September 14, 2006 | 5:46 am

Whenever I script an object within a bpatcher, it will be positioned
relative to the main patcher, which renders scripting of visible objects
useless within a bpatcher.

I wanted to move a slider two pixels to the right, and it was moved way
out of sight.

steps to reproduce:
load the below patcher into a bpatcher and place it more to the right…

click the script, watch the slider disapear.

expected result:
move according to the internal coordinates of the bpatcher as it does
with normal patchers…

possible workaround:
If there would be a way to get the information about the properties
(position and size) of a bpatcher into the bpatcher, I could patch
around that problem.

Max 4.6.1, OS X 10.4.7, Powerbook 12" PPC

#P window setfont "Sans Serif" 9.;
#P window linecount 2;
#P message 36 100 65 196617 script move slide 15 10;
#P window linecount 1;
#N thispatcher;
#Q end;
#P newobj 36 137 62 196617 thispatcher;
#P user uslider 10 10 18 128 128 1 0 0;
#P objectname slide;
#P connect 2 0 1 0;
#P window clipboard copycount 3;


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


September 14, 2006 | 6:08 am

This is pretty standard fair. just about all of the coordinates and
scrolling is done relative to the main patcher. I think its a tad
counter intuitive but its been discussed before. obviously the work
around is to get and use the top/left coordinates of the bpatcher.

if your not in js jasch’s posit object should do the trick

other than that, I give the floor to a more senior maxman
-matt


September 14, 2006 | 6:35 am

matthew aidekman wrote:
> if your not in js jasch’s posit object should do the trick

Thanks to the pointer. If somedy has a js solution to get the
coordinates of a bpatcher, that would be great as well…

For the relative moving its actually not a problem as I found the offset
scripting command.
The other workaround is to place all potential objects in there and
delete those which are not needed. Thats what I do now…

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


September 14, 2006 | 9:08 am

put this into a javascript inside your bpatcher (it works for
subpatchers in general).

this.patcher.box.rect

hth

/*j

>> if your not in js jasch’s posit object should do the trick
>
> Thanks to the pointer. If somedy has a js solution to get the
> coordinates of a bpatcher, that would be great as well…

/////////////////////////////

save as get_bpatchercoords.js

/////////////////////////////

/*
* get the coordinates of the bpatcher box – jasch 20060914
*/

function bang()
{
outlet(0, this.patcher.box.rect);
}

/////////////////////////////

save as whatever

/////////////////////////////

max v2;
#N vpatcher 9 59 609 459;
#P window setfont "Sans Serif" 9.;
#P flonum 41 206 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname flonum[3];
#P number 41 184 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname num[3];
#P flonum 42 160 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname flonum[2];
#P number 42 138 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname num[2];
#P flonum 43 114 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname flonum[1];
#P number 43 92 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname num[1];
#P bpatcher 285 163 163 124 0 0 bpatchercoords_sub.mxb 0;
#P bpatcher 285 35 163 124 0 0 bpatchercoords_sub.mxb 0;
#P bpatcher 117 163 163 124 0 0 bpatchercoords_sub.mxb 0;
#P flonum 44 68 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname flonum[0];
#P number 44 46 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname num[0];
#P bpatcher 117 35 163 124 0 0 bpatchercoords_sub.mxb 0;
#P window linecount 1;
#P comment 32 230 59 196617 other stuff;
#P pop;

/////////////////////////////

save as bpatchercoords_sub.mxb

/////////////////////////////

max v2;
#N vpatcher 158 146 758 546;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 128 99 41 196617 bottom;
#P comment 91 99 32 196617 right;
#P comment 54 99 22 196617 top;
#P number 91 81 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 128 81 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 17 81 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 54 81 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 17 62 123 196617 unpack 0 0 0 0;
#P button 17 20 15 0;
#P newex 17 40 123 196617 js get_bpatchercoords.js;
#P comment 17 99 24 196617 left;
#P connect 2 0 1 0;
#P connect 1 0 3 0;
#P connect 3 0 5 0;
#P connect 3 1 4 0;
#P connect 3 2 7 0;
#P connect 3 3 6 0;
#P pop;


September 14, 2006 | 10:04 am

/*j wrote:
> put this into a javascript inside your bpatcher (it works for
> subpatchers in general).
>
> this.patcher.box.rect

Thanks a lot, much simpler than I thought…

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


September 14, 2006 | 4:40 pm

Stephan – the other method is to use the offsetfrom var, var2 method
to thispatcher, and use a hidden named object within the bpatcher to
use as your new origin.

jasch:

the problem with this solution is that it only gets the box
coordinates from within the bpatcher, relative to the bpatcher, as
far as Ive seen on my max 4.6.1.

if I have an ubumenu within the bpatcher, and I want to get its
global , absolute coordinates relative to the screen, how do I do it?
I cant seem to figure it out …

I posted this question recently in the JS forum. Any help?

BTW, that bpatcher coordinate issue is really really really non-
intuitive, and IMO should be fixed. or set as an option in the
bpatchers inspector to choose the coordinate system.

v a d e //

http://www.vade.info
abstrakt.vade.info

On Sep 14, 2006, at 6:04 AM, Stefan Tiedje wrote:

> /*j wrote:
>> put this into a javascript inside your bpatcher (it works for
>> subpatchers in general).
>> this.patcher.box.rect
>
> Thanks a lot, much simpler than I thought…
>
> Stefan
>
> —
> Stefan Tiedje————x——-
> –_____———–|————–
> –(_|_ —-|—–|—–()——-
> — _|_)—-|—–()————–
> ———-()——–www.ccmix.com
>


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