bpatcher default size

eeeeaaii's icon

Hi,

I would like to make it so that when I open a certain file (let's say it's foo.maxpat) within a bpatcher, it will always open in a certain size. In other words, the size of the bpatcher window will change depending on the settings in the file that is loaded into the bpatcher window.

The way it works now is that you can change the size of the bpatcher window in the LOADING patcher, but that doesn't make much sense. The LOADED patcher controls everything else such as size/shape/arrangement of controls, background color, etc. I'd like for it to also control the size. Does that make sense?

seejayjames's icon

probably can do it with javascript, it has access to the loaded patcher's attributes, not sure of the exact way to do that. Also you can get at the patcher size by parsing the patch text, but that's probably too cumbersome.

If whatever patch you want to load has a [loadbang] that sends out the patch's dimensions, you could use [send] to get the size to your main patch and change the bpatcher's box to match right when it's instantiated.

Tj Shredder's icon

I simply make prototypes for this purpose. It will even remember all these other settings like file name and arguments and I don't know what...
I have currently 23 prototypes for bpatcher and more to come...
No fancy scripting necessary, though possible as well...

Stefan

Marcin's icon

Hi,

I've been struggling with same problem for a while and I've just found a solution. It's not as straightforward as I would wish, so if anyone's got a better idea, I'm all ears :)

1. create empty bpatcher in your parent patch
2. give the empty bpatcher a javascript name (the "varname" attribute)
3. assign your child patch file to the bpatcher

now inside your child patch file you need 4 objects:

loadbang
|
delay 5000 // you have to delay the bang, otherwise "this.patcher.box" inside javascript won't be initialized at the moment of execution
|
message "initializeRect"
|
js code.js

The "code.js" file looks like this:
function initializeRect() {
var myname = this.patcher.box.varname;
var parent = this.patcher.parentpatcher;
parent.message("script", "sendbox", myname, "patching_rect", 100, 200, 300, 400);
}

tinez