Forums > Javascript

newobject() arguments for bpatcher


Aug 03 2010 | 10:41 pm

Hi,

As my first foray into JavaScript within Max, I’m trying to do automate the creation of a series of bpatchers, similar to the example in the "JavaScript Scripting" tutorial.

I have to admit, I’m having some trouble figuring out the order of arguments for newobject() from looking at the documentation. First I tried this:

numbpatchers = a;
for(k=0;k
{
thebpatchers[k] = this.patcher.newobject("bpatcher", "FloatingButtons.maxpat", k*100, 0, (k+1)*100, this.patcher.wind.size[1]);
}

Then this:

numbpatchers = a;
for(k=0;k
{
thebpatchers[k] = this.patcher.newdefault(0, 0, "bpatcher");
thebpatchers[k].replace("FloatingButtons.maxpat");
thebpatchers[k].rect(k*100, 0, (k+1)*100, this.patcher.wind.size[1]);
}

But neither seem to work as desired. All I want to do is set the rectangle (actually in presentation, but I’m just trying to get it running at this point) and file. I’m sure this is very simple, I just can’t seem to find many examples of scripts that create new objects other than the one in the tutorial that uses newdefault() and doesn’t set any parameters.

Thanks,
Zach

Aug 03 2010 | 11:13 pm

Is FloatingButtons.maxpat in your search path? If not you will have to use the full file path to get this to work. The second method where you call replace() works for me.

lh

Aug 04 2010 | 7:26 pm

It is in the search path. The second method loads the file, but the rectangle is not correct. It should create 100 pixel wide vertical strips that are the same height as the window. As noted, I’d also like it to set the presentation rectangle if you could point me to that function.

Please correct me if I’m wrong, but it seems I should be able to create the object and set all of these parameters by just calling newobject(). But how do I find out the correct argument order for bpatcher, or any object for that matter?

Thanks,
Zach

Aug 06 2010 | 4:29 pm

Any ideas?

Thanks,
Zach

Nov 27 2011 | 5:52 am

Did you ever get this figured out?

Dec 21 2011 | 2:47 pm

interested too
digging that actually (I mean now)

Dec 21 2011 | 5:31 pm

This works fine for me:

function createBpatcher(file,varname,args)
{
offset = this.patcher.box.rect;
object = this.patcher.parentpatcher.newdefault(offset[2],offset[1],
"bpatcher",
"@name", file,
"@patching_rect", (offset[2]+5), offset[1], "128", "128",
"@presentation_rect", (offset[2]+5), offset[1], "128", "128",
"@border", "0",
"@varname", varname,
"@args", args,
"@orderfront", "1",
"@hint", varname,
"@embed", "0",
"@presentation", "0");
}

Dec 21 2011 | 5:34 pm

reminds me overriding of class in other worlds ;-)
thanks for your post, it helps me right now :)

Dec 21 2011 | 6:33 pm

this.patcher.newdefault(0,0,"bpatcher","@name", path);
creates a patcher without name, but no complains in max window

any ideas?
it sounds very weird :-/

Dec 21 2011 | 9:37 pm

I meant, it doesn’t create a bpatcher and I don’t know why ?!
(max6)

Dec 21 2011 | 10:07 pm

WEIRD.
I just quit, reload. it is ok.

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

Forums > Javascript