View Full Version : Python setState mel Command

09 September 2010, 11:20 PM
I'm trying to use mel's setState command so I can turn off the evaluation of ik solvers, but there are two problems I'm having. A) Python doesn't have this command; B) When I try to use mayas import maya.mel it tells me: "AttributeError: 'module' object has no attribute 'setState'". So how would one go about doing this?

Here's what I attempted:

import maya.mel as mel
p, li { white-space: pre-wrap; } mel.setState('true all;')
mel.setState('true iksolver;')

Neither obviously works, since the error thrown earlier says that it's not even an option. So how would one go about doing this?

09 September 2010, 11:36 PM
Sorted it out:

# off
cmds.setAttr('ikSystem.globalSolve', 0)
# on
cmds.setAttr('ikSystem.globalSolve', 1)

I'd still like to know how to disable all node evaluation, but this works. :)

09 September 2010, 01:06 PM
in the "mel" module there is really just the "eval" command (check with dir if you want) that you can use to run MEL commands from python. So you're actually right about the module yet ;]
import maya.mel as mel
mel.eval('setState "expression" on;')
note that this is actually a bit dirty to run mel from python.. But really seems there is no other way in this case :D

09 September 2010, 10:47 PM
Awesome post ewerybody! And I had felt the same way about it being dirty to do it, but to turn everything off, that is the only way. But I really only needed the RPSolver, so that works for this particular application. I wonder why it's a mel only command though. Is there an API equivalent? I looked, but didn't find anything that looked useful, although my knowledge of the API is fairly limited, so I may have looked over it. Thanks for letting me know that though!

CGTalk Moderation
09 September 2010, 10:47 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.