newobject() arguments for bpatcher

Aug 3, 2010 at 10:41pm

newobject() arguments for bpatcher

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

#51626
Aug 3, 2010 at 11:13pm

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

#185242
Aug 4, 2010 at 7:26pm

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

#185243
Aug 6, 2010 at 4:29pm

Any ideas?

Thanks,
Zach

#185244
Nov 27, 2011 at 5:52am

Did you ever get this figured out?

#185245
Dec 21, 2011 at 2:47pm

interested too
digging that actually (I mean now)

#185246
Dec 21, 2011 at 5:31pm

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″);
}

#185247
Dec 21, 2011 at 5:34pm

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

#185248
Dec 21, 2011 at 6:33pm

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 :-/

#185249
Dec 21, 2011 at 9:37pm

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

#185250
Dec 21, 2011 at 10:07pm

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

#185251

You must be logged in to reply to this topic.