Is it possible to move objects in a locked patch with js ?
I’m trying to get my bearings on my first few js patches, and here I’ve gotten stuck. I’ve made a patch that creates bpatchers and gives them scripting names in sequential order, connecting the first to the second..and so on. I’m trying to make the patch so if you move the second bpatcher above the first, the connections change order, so 2 goes into 1… that for right now isnt the trouble…. If the bpatchers can’t be moved while the patch is locked, the idea is less enticing and I’ll have to figure something else out. Any advice.. ? Thanks !
Hmm…. I don’t remember if I’ve tried moving js objects from within a locked patch – but I’ve certainly created new objects galore inside locked patches without an issue.
I tend to think that the JS stuff doesn’t respect locked-ness – that’s a UI thing only.
Are you saying that you have code that runs correctly in an unlocked patch, and then fails when you lock the patch and try again? Can you post your code here?
I think i figured out what I needed to. It is entirely possible. the ‘script offset’ to thispatcher works. Thanks for your quick replies. and a short follow up.. I tried to use mousestate in my bpatchers to give me their relative position to one another so their connections can change… it was troubling. But I found an external I’ve never used called [posit], in the Jash library which can query x-y coordinates of objects with scripting names. Does anyone know how to do this without externals?
Luke, what have you run into with bpatchers and js that caused trouble ? i’m almost depending on it for this program. so any heads up would be appreciated. Luke, you answer a lot of questions for me in this forum. I should have gotten you a christmas present.
var obj_pos = this.patcher.getnamed(someScriptingName).rect;
where the obj_pos variable will be an array of the position as it would appear in the object inspector.
If you have any other questions or you want me to take a look at the patch/code you have so far then post it here. Any presents you can save until my birthday in April!
I didn’t write it on this forum, but I did have some trouble creating bpatchers, though I didn’t really follow it down.
The issue is that the identify patch contained in it isn’t set with an argument to the bpatcher box, but with a parameter; yet, trying to set that parameter after the bpatcher is created doesn’t seem to bring that patch into the patcher.
YMMV; I experimented and went a different way.
creating bpatchers with a patch inside is possible if the associated file is in the same folder.
[script newobject bpatcher @name getsize.maxpat]
–>But I found an external I’ve never used called [posit], in the Jash library which can query x-y coordinates of objects with scripting names. Does anyone know how to do this without externals?< --
[pattr] can bind to an object’s attributes as well as its state. Check the Help file to see the syntax. In this case you can bind to the object’s patching_rect or presentation_rect, so the top/left/width/height values will be shown in real-time in the patch. Running them though some number boxes and back into a message "patching_rect $1 $2 $3 $4" and to the object, you can store object positions (as pattrstorage slots) after moving the objects with the mouse. You will need a "set" at the correct place to avoid a stack overflow though :)
best part about this is to then interpolate between your stored slots, which moves and resizes everything!