True False flags in python when running in maya

   7174   3   2
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
Hey guys, has anyone seen this weird issue, where when writing some python code in a python module such as:

import maya.cmds as cmds

print cmds.ls(sl=True)

returns this error:

Flag ‘sl’ must be passed a boolean argument

there appears to be something strange going on with the True keywork flag which I cannot seem to figure out… using 1 instead yields the same result
-G
User Avatar
Member
818 posts
Joined: Sept. 2013
Offline
Ah, another user actually reported the same issue. It took a while to hunt down the problem. That error message is actually not the real error, so it's misleading. The real problem comes from a limitation of Maya's cmd module. There are two workarounds. One is to simply use the mel equivalent.

The other workaround is to is disable asynchronous mode in the Maya plugin. I recently added a preference to specifically workaround this issue. However, by turning off asynchronous mode, you lose some nice features like progress bar and interrupts. :?
Andrew / アンドリュー
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
Thank you so much Andrew! You are a life saver!

Would using pymel also resolve the issue?
-G
User Avatar
Member
818 posts
Joined: Sept. 2013
Offline
I think many parts of pymel still uses the cmd module underneath. So it'd probably suffer from the same problems.
Andrew / アンドリュー
  • Quick Links