MuscleStudio

I have written a MuscleStudio Script that creates a Single Muscle that can then be placed into Rigs. Also I have written a UI that controls the behaviour of the muscle itself. The problem that I am having is this...

Everything works fine with just the one muscle in a scene, but as soon as I duplicate or import a 2nd one, the UI no longer controls either of them. I had hoped to be able to use the UI as a generic 'tool' to control each muscle once it has been selected.

Is there a way to make a 'selected' muscle the one that the UI can use? I have tried using get, set and put etc but with no luck. I am guessing that I need to make a selected muscle somehow 'current' on a selection list or something. I will also add
a namefield or add-selected button in the UI to handle this, but am unsure of how
MEL works with this sort of thing. Plus I am not really a coder at all : (

Any help or info would be greatly appreciated as I am hoping to build a free muscle
tool that anybody can use : )

A similar situation is in the FinalRig script from Radiant Square whereby you get to select a node both within the persp view and the UI and all UI controls work with the currently selected Rig.

I have UI's that function on our character rigs... you can have as many characters in scene as you'd like, and when you access the UI by pressing a button on the character, the UI rebuilds itself with all of it's commands affecting the appropriate nodes on the appropriate characeter. One thing I do is declare optionVar's for the "current character". This is usually a prefix for all nodes on that character. My UI's commands base themselves on the base name of the characters nodes, plus the prefix stored in the optionVar. By setting it up this way, whenever I update the UI on a new character, new optionVar's for that particular character are declared, and the UI now functions on that character, and only that character. It does this, again, by adding the custom prefix name in the optionVar to the hard-coded node names in the UI. Makes it procedurally regenerate itself for each character. I think it would work really easily for your muscle setup as well.