newbie help with js object scripting

Tom Mays's icon

In spite of being a very long time maxer, I'm a total newbie to javascript, and I was hoping someone could point me in the right direction.

I'm trying to create a delete poly~ objects via js scripting, and I'm able to do this with patcher.newdefault and this.patcher.remove, so that's cool. But, when I close the patch and reopen. The scripted objects are no longer connected to the js variables. So if I try and delete an object that I had scripted previously, my js code doesn't have any idea what object I'm referring to and thinks it's already deleted.

So, could someone point me in the direction of a solution?

To be clear, I want to:

  1. create one or more objects via js scripting (poly~ with different loaded patches and arguments) - this I found a simple method for.

  2. save the patch including the scripted objects, quit max.

  3. re-open the patch and be able to continue to control the scripted objects with the same js object and code – reconnect the scripted objects to js so that they can be deleted and re-created.

A possible idea: can you search for a scripting name and associate that object to a variable in js?

Thanks in advance.

cheers,

Tom

Tom Mays's icon

Found it...

myjsvariable = this.patcher.getnamed("scriptingname");

assigns object with a that scripting name to a js variable (myjsvariable).

Problem solved.

-t