Set abstraction name with argument
(OS X.3.9, MMJ 4.5.5)
I want to be able to set the object name of instances of my abstractions with an argument, a la buffer~, but can’t seem to find a way of doing so. In JS this.patcher.box returns nothing (I guess because its an abstraction, not a subpatch), and there doesn’t seem to be a scripting solution.
If someone knows a way, or can direct me to a part of the fine manuals that I’ve missed, I’d be most grateful.
In fact, not like buffer~ at all, because I was looking for a way to set the objectname that you see in the inspector.
Are you trying to use a script within an abstraction to name its containing box after it is created? I was trying to do this and couldn’t figure it out using this.patcher.box, so I found a work around that you may find useful.
Once the abstraction has a name you can rename it from a script inside. Use parent = this.patcher.parentpatcher, then parent.getnamed to get a maxobj of itself and remname it using varname. If there’s a way to do it with this.patcher.box someone please let us know.
haha just kidding! I’m new.
I was calling the this.patcher.box from the loadbang function in the script and this doesn’t work. You have to schedule the task at a later time (0 ms seems to work though). The same is true for parentpatcher, and probably other functions that return patcher and maxobj objects.
So… when your abstractions are created you can use this.patcher.box, then varname to set the name of your new abstraction. You just can’t do it in the loadbang function, or from a [Task].execute() in the loadbang function. [Task].schedule(0) works in the very simple example I just cooked up.
I seem to remember that this came up before, maybe under a different guise.