Constraint Switching with MEL


#1

Hello, I’m feeling stuck and I’m looking for some help. I’m working on a rubik’s cube rig and I’m trying to create an expression that will allow me to turn on contraints when a control is selected. To do this I’m trying to perform a check if the position of my cube object is the same as a static locator.

I’ve not been working with python or MEL very long and I don’t have a background in programming so I’m not sure what I’m doing wrong but I’ve got a bunch of syntax errors. My first problem is I’m trying to load a bunch of objects to test their tranlate X Y or Z values against locators but I don’t know how to make it work without getting “illegal operation == on data type float” and a variety of other syntax errors.

here is a sample of my code I’ve create to try doing this…

[I]float $Obj_Constraint_Toggle[] = {array of objects};

//Query selection…
float $selCtrl[] = ‘ls -sl’;

//Check for which control is selected…
if ($selCtrl == red_ctrl1){
//for red control, cycle through locator checks and any object that has the same location as locator has contraint turned on…
for ($redSideCubes in $Obj_Constraint_Toggle){
if ($redSideCubes.translateX == locAlign_rby_corner_Cube01.translateX){
setAttr $redSideCubes + “_orientConstraint1.red_jntW0” 1;
}
//else perform same cycle and set all red contstraints to zero…
} else {
for ($redSideCubes in $Obj_Constraint_Toggle.translateX){
setAttr “$redSideCubes_orientConstraint1.red_jntW0” 0;
}
}[/I]

anyone able to help?