PDA

View Full Version : calling mel commands from python


onehope
12-06-2010, 05:30 PM
Hi I'm new to python in maya and I have a problem:
I have this variable:

grouped = ['locator1', 'locator2', 'locator3']

and I want to get the top parent of grouped [0], as far as I know commands like "rootOf" or "firstParentOf" do not exist in python so I have to call them from mel like that:

from maya import mel as mm
mm.eval("rootOf(\"locator1\");")

but instead of "locator1 "If I want to use a value from a python variable like :

from maya import mel as mm
mm.eval("rootOf(grouped [0]);")

obviously I get a runtime error so
.....how can I do that??
Is there any other way to do it?

thanks

D

NaughtyNathan
12-06-2010, 05:45 PM
one way:
mm.eval('rootOf '+grouped[0]):nathaN

onehope
12-06-2010, 06:16 PM
Thanks dude

You saved my life, and it's not the first time!! :-D I hope someday I can buy you a beer!!

D

CGTalk Moderation
12-06-2010, 06:16 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.