Calling Python scripts from Maya MEL menuItem

Hey Guys,

I have a problem with passing MEL variables to a Python script from a MEL script.

this works:

menuItem -l “mirror ctrl” -c “python(“import Mirror;Mirror.mirror()”)”;

Then I try to pass the $object variable and the number 1 to the script and I get syntax error:

menuItem -l “mirror ctrl” -c “python(“import Mirror;Mirror.mirror(””+$object+"", 1)")";

Any ideas?

I am creating a dropdown menu when you right click a control on a rig, I have to use MEL because I am making changes in the dagMenuProc.mel script.

Cheers!

Try putting parentheses around the command string, to make sure the whole thing gets parsed as a single entity:

menuItem -l "mirror ctrl" -c ("python(\"import Mirror;Mirror.mirror(\""+$object+"\", 1)\")");

Thanks, It runs the script and it gets the MEL variable now but it still gives a syntax error.

// Error: python(“import Mirror;Mirror.mirror(“armL”, 1)”); //
// Error: Line 1.51: Syntax error //

fixed it :D, this works!

menuItem -l “mirror ctrl” -c (“python(“import Mirror;Mirror.mirror(’”+$object+”’, 1)")");