Message 1 of 3
Python API 2.0 - executeCommand

Not applicable
05-31-2021
05:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In Python API 2.0 executeCommand was removed.
What way now to perform MEL code In Python API 2.0?
In Python API 1.0 this way is work fine -
import maya.OpenMaya as OpenMayaOld
mIntArray = OpenMayaOld.MIntArray()
cmd = ("global string $gPlayBackSlider; "
"$gPlayBackSlider = $gPlayBackSlider;"
"$temp2 = `timeControl -q -ra $gPlayBackSlider`;")
OpenMayaOld.MGlobal.executeCommand( cmd, mIntArray, False, False )
print (mIntArray)
#[1, 4]
In Python API 2.0 this way is NOT work -
import maya.api.OpenMaya as OpenMaya
cmd = ("global string $gPlayBackSlider; "
"$gPlayBackSlider = $gPlayBackSlider;"
"$temp2 = `timeControl -q -ra $gPlayBackSlider`;")
result = OpenMaya.MGlobal.executeCommandStringResult( cmd, False, False )
print (result)
# Error: (kFailure): Unexpected Internal Failure
# Traceback (most recent call last):
# File "<maya console>", line 7, in <module>
# RuntimeError: (kFailure): Unexpected Internal Failure #