scripting the color of a patchcord

thispatcher's icon

Hi there! I want to be able to change the color of a patchcord using a script message to [thispatcher] ... or js, but my js knowledge is not that strong. I assume I would need to know the outlet and inlet that a given patchcord is attached to, which is fine, I just don't know the command for this. hopefully there is a solution!! :D

Ben Bracken's icon

Here is an example with thispatcher:

Max Patch
Copy patch and select New From Clipboard in Max.

thispatcher's icon

Hey! This is great, thank you Ben!!!

Roman Thilenius's icon

both objects must have a scripting name, then you can simply delete and recreate the connections.

hrm. mabye some day we´ll have some sort of greasemonkey button on top of the window which can perform scripts right on a selection of objects.

thispatcher's icon

that's a compelling idea, Roman!

as per your solution, it could work in other cases, but in mine, I need the cables to remain connected as some of them are msp cables.

I have another request, is it possible to script a cable to the front of the canvas? This is available through the patchcord menu, but I haven't yet seen anything in the docs about how to do this via script. Thoughts?

Roman Thilenius's icon

well, then let´s be honest, currently it is three clicks to use the inspector or apply a style to a selection. an alternate solution should be something which is even faster to apply, otherwise it is worthless.

to my knownlegde a connection isnt scriptable, only its creation. you would have to script the object boxes in question to the background to get that result. or unlock the patcher :)

thispatcher's icon

well, then let´s be honest, currently it is three clicks to use the inspector or apply a style to a selection. an alternate solution should be something which is even faster to apply, otherwise it is worthless.

I hear you, but it needs to be scriptable because I want the patchcords to be coloured whenever they are being acted on by a given MIDI controller number. I'll post something once its working solidly.

to my knownlegde a connection isnt scriptable, only its creation. you would have to script the object boxes in question to the background to get that result. or unlock the patcher :)

I've actually got cable scripting working, thanks to Ben's solution for colours, i just haven't yet found the script command for bring-to-front/send-to-back. I'll post as soon as i figure it out :)

Ben Bracken's icon

As far as I know, you can't really set a patch cord's layer, but you can add objects to the background layer:

Max Patch
Copy patch and select New From Clipboard in Max.

Is that what you mean?

thispatcher's icon

Ah, that's not quite it. I have a lot of patchcords in a patch, and for a performance I'm changing the colour of all the patchcords that are currently in the path of a given midi controller (with corresponding colour). That part is working very well, thanks to your help. This last part, which I recognize may not be possible, is to bring a given patchcord forward, because even if it is coloured, if there are other patchcords on top, the colour change will be (partially) obscured.

Roman Thilenius's icon

cant you make a simple "patchcord" interface with lcd, mgraphics, or picture files?