it must have to do with what scope the "python" mel command is run
in. the most straightforward solution is to format the eval'd mel
string with the variable value:
mel.eval('AEnewNonNumericMultiAddNewItem("%s", "input3D");' % tmp )
alternately, if you're using pymel, you can just pass the value as if
it were a python script:
pymel.mel.AEnewNonNumericMultiAddNewItem( tmp, 'input3D' )
pymel will save you a lot of formatting head-ache when you start
passing string arrays, vectors, etc.
-chad
On May 8, 2009, at 9:48 AM, mputtkam wrote:
>
> Hi,
>
> This is about passing python vars to mel using an externally sourced
> python script in maya 2008:
> Simplified example:
>
> import maya.cmds as cmds
> import maya.mel as mel
>
> joints = []
> for i in range(5):
> joints.append(cmds.joint())
>
> def test():
> global tmp
> for i in range(5):
> tmp = joints[i] + '_sum_up_inputs_calc'
> cmds.shadingNode('plusMinusAverage', asUtility = 1, name =
> tmp)
> mel.eval('string $tmp = python("tmp")')
> mel.eval('AEnewNonNumericMultiAddNewItem($tmp, "input3D");')
> test()
>
> Paste it in Maya. It should work. At least it does for me. However, it
> does not work for me, when I source it via the usual import/reload
> procedure using an external .py. Maya will then read: "Tmp not
> defined".
>
> I do not get it. I go crazy over it, because it does not make sense.
> Paste directly, works. Source externally, does not. I tried putting
> global tmp all over the place, but that did not help either. If I
> source the script twice, the previously errored utility will suddenly
> have four(!) inputs, while the other new ones will not have any.
> That's weird for sure. I do not know what else to try to get this
> working...
>
> Help is much appreciated.
> Martin
>
> Thanks,
> Martin
>
> >
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---