Get size of this bpatcher?

discopatrick's icon

If you have an abstraction being displayed in a bpatcher, is it possible for the abstraction to get the size of the bpatcher?

Lee's icon

Hi, not sure how to do this in normal Max, but the following js will give you the bpatcher size if called from within:

inlets = 1
outlets = 1

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

discopatrick's icon

Amazing, thanks Lee.

I will call this code on patcher load, to resize the bpatcher contents based on the size of the bpatcher.

Is there a way to have this code execute automatically after each time the bpatcher is resized?

Lee's icon

No, don't think so - if you need to get updated, best thing to do is set up a metro object to fire the message into the js every x ms and respond to changes in the result