how i can pass python variable in mel

31 views
Skip to first unread message

Virbhadra Gupta

unread,
May 28, 2017, 4:12:26 AM5/28/17
to Python Programming for Autodesk Maya
how i can pass python variable in mel??
in my example mel_path in not giving what is supposed to give
anims_path  is giving proper path like "D:\del\malcolm_v109_malcolm.anim"
but mel_path giving  "d:/"
please help me out.

for obj in objs:
    object_name = renamer (obj)
    cmds.select (obj)
    anims_path = path_input+ platform_tester ()+ object_name +'.anim'
    mel_path = mel.eval ('$mel_path = python("anims_path")')

Justin Israel

unread,
May 28, 2017, 8:19:49 AM5/28/17
to Python Programming for Autodesk Maya
It could be an issue with the scope of the variable when calling python from Mel. 

You can really share variable between them in a native sense. Just evaluating the values back and forth. Can you just string format the value to pass it to Mel? (untested) 

mel.eval ('$mel_path = "%s"' % anims_path)

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a81a312c-72eb-4313-acfa-12ae7de19937%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Virbhadra Gupta

unread,
May 28, 2017, 8:27:43 AM5/28/17
to Python Programming for Autodesk Maya
Thanks!!!
it worked :)
Reply all
Reply to author
Forward
0 new messages