Forums > MaxMSP

Quick question about bpatchers

May 24, 2011 | 12:54 am

I have a quick question about bpatchers. The way I do it now is I create a bpatcher object, go to the inspector, load in the file, go back to the main patch, press shift and control to drag the internal contents where I need them to be, then I resize the bpatcher window. Not much of a hassle but I would prefer something like PD’s "graph on parent" or to be like the Vizzie abstractions. I looked at the Vizzie Kit but it’s a lot more than I need.

Also just a note in the bpatcher reference it says "if Control and Alt keys on Windows are held down while clicking in a bpatcher object, a pop-up menu allows you to open the original file of the patch contained inside the box in its own window, or change the patch currently contained inside the box in its own window." – I could not get this to work – Max 5.1.8 XP and Vista. Is is just me?


May 24, 2011 | 2:21 am

I prefer to build my bpatchers and put them into presentation mode where only the elements I want to see show. Then, using the inspector, I set the patcher size to only show the elements I want to see AND to always open in presentation mode. Then when I use them in other patches, they are already configured to the right size/display.

Sorry, I’m a Mac user, so I can’t answer your 2nd question.


May 24, 2011 | 2:44 am

I wrote a javascript that will automatically resize and reposition the patcher living in a [bpatcher] when the patch loads which has proved useful. The code is below. If you give the object the argument 1 it will use only objects in presentation mode (make sure you select the patch to open in presentation mode too) the default behaviour is to use all objects in the patch. Here’s the code, it could probably be optimised a bit, let me know if you’d like an example to demonstrate how it works.

// lh.bpresize.js

var edges;
var mode = (jsarguments[1]>0);
var obj;

function loadbang() {
    if (!max.loadbangdisabled) {
        bang();
    }
}

function bang() {
    edges = [Number.POSITIVE_INFINITY,
        Number.POSITIVE_INFINITY,
        Number.NEGATIVE_INFINITY,
        Number.NEGATIVE_INFINITY];
    this.patcher.apply(iter);
    move = [edges[0]*-1,edges[1]*-1];
    size = [edges[2]-edges[0],edges[3]-edges[1]];
    if (this.patcher.box) {
        this.patcher.box.message("offset",move);
        a = this.patcher.box.rect;
        this.patcher.box.rect = [a[0],a[1],size[0]+a[0],size[1]+a[1]];
    }
}

function iter(a) {
    obj = a;
    if (mode) {
        if (a.getattr("presentation")) {
            calc();
        }
    } else {
        calc();
    }
}

function calc() {
    if (mode) {
        attr = "presentation_rect";
    } else {
        attr = "patching_rect";
    }
    for (i=0; i<2; i++) {
        if(obj.getattr(attr)[i]edges[i]) {
            edges[i] = obj.getattr(attr)[i]+obj.getattr(attr)[i-2];
        }
    }
}

function setmode(x) {
    mode = (x>0);
}

// EOF

May 24, 2011 | 2:48 am

The latter point seems to be like right clicking the [bpatcher] and selecting Object > Open Original. If you’ve embedded the [bpatcher] in the parent file you can also use Object > New View which can be useful too.


May 24, 2011 | 6:09 pm

Thanks BK & Luke. I tried to set the initial fixed patcher window size in the subpatch and open in presentation – better. It doesn’t seem to have any impact when I create an the bpatcher object in a new project. I still have to resize the bpatcher window. It’s not a hassle but the Vizzie drag and drop objects are cool and I have something similar in PD. Never quite figured it out in Max. Thought I was missing some little function button or trick.

@Luke – Thanks for the Java. I’ll give it a go. The CLT+ALT click is not working in PC (just noticed so I thought I’d mention it). Right click works alright but not CLT+ALT click – meant to try it on the Mac in work today and forgot.


May 24, 2011 | 8:22 pm

i create what i need, use a space of a known size, then move it to position 0 0.

when i create the bpatcher i only have to set it to the size which i already know.


November 14, 2011 | 5:08 pm

I just made an automatic bpatcher, maybe its interesting for you… with this your abstraction open always as bpatcher, when included in other patches

http://www.rbtnk.org/max-msp/

Attachments:
  1. autoBpatcher.zip

September 1, 2013 | 3:35 am

Thank you timtation, that is a nice patch. The only thing is that it does not add the patcher arguments to the bpatcher object. I’ll try and see if I can add that functionality myself.


September 1, 2013 | 4:45 am

Thanks Timtation I’m just seeing this now. Can’t check it out now but I will when I get home. As of right now I just copy what Stretta did with his BEAP master clippings.

I make a patch (foo), give it a presentation, position the presentation at 0 0 on the screen, and set the patch to open in presentation.

Then I make a new patch, create a bpatcher, load in foo, set the bpatcher to ‘embed in parent’ and then save the patch as a clipping.

Now I have my own reusable bpatcher GUI elements in a clipping folder. It was probably this simple all along but the code inside the Vizzie stuff put me off. It was much more obvious with Stretta’s BEAP package.


September 1, 2013 | 6:27 am

In my opinion clippings have some problems/missing benefits:
- if you use bpatcher in clippings, mostly the original patch is anywhere, but not in the clippings directory
- everytime i install a new version of max, my custom clippings in the clippings directory are gone
- and its not typing a name in an object box and have everything you need, its a different procedure…

Best Tim


September 1, 2013 | 11:49 am

-use ‘embed patcher in parent’ is a better idea for a clipping ?
-ah ye. :/ since 6.1.3 you can make a custom folder in the packages, then a ‘clipping’ folder, i suoppose the package folder won’t be affected by future update (at least the one in Documentation/.)
-it’s a different need ! :)


September 1, 2013 | 2:03 pm

Timtation, is it also to connect the newly created bpatcher to everything that the old object was connected to?

And how would you copy the creation arguments to the bpatcher’s arguments property? I tried inserting this at line 128 of the JavaScript file, but it doesn’t work: bpatch.args(this.patch.args); It does work to do something like bpatch.args("test 1 2");, this creates three arguments: test, 1 and 2 …

How do you get in JavaScript the creation arguments that were entered after the object name?


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