Script a snippet in to a patch

nouserid's icon

Just wondering if there is a message for thispatcher that will allow me to paste a snippet in to the patch. I know you can right click and "paste from" but I'm hoping to be able to create my own menu system for my snippets.

2K's icon

+ 1

Roman Thilenius's icon


if anywhere, then in javascript.

snippets arent objects...

2K's icon

Yup ur right! Anyway I couldn't find anything related on how to add a snippet from js.

nouserid's icon

If you can load up a snippet from the right click menu then shouldn't there be some way of recreating that action from inside the patch itself?

Roman Thilenius's icon


what technically could be possible is to add a "recording" mode to thispatcher scripting. i am wishing for that for a long time. you wouldnt not need to have invented "snippets" if that would work, you could just save a "thispatcher script" to disk.
of course the last created object in the patch will always keep the name, but that would be a minor problem.

i have no idea about javascript itself, but if you open a snippet as text you will find that it has a structure similar to a patcher file.
the hardest part would be to insert stuff relative to mouse position.

Wetterberg's icon

yeah, if you open a maxsnip file in textedit, you can copy the text and just paste it into your patch like you would with a normal patcher, too.

Roman Thilenius's icon


what else would be needed to reproduce the built-in function.

find by name, open as text, copy and paste, reposition, set dirty bit. whats more?

can snippets contain styles?