Hey there!
Is there some (un)known bug with MPxContextCommand’s setResult method in API 2.0 (Maya 2023/2024 - same issue in both versions):
OpenMayaUI.MPxContextCommand.setResult()
I’m querying a flag value and trying to return string from command (in ‘doQueryFlags’ method), by setting result, but can’t seem to make it work - method will accept ints, bools, floats, with no issue, but when I pass to it a string, it errors:
self.setResult("flag")
(kFailure): Unexpected Internal Failure
self.setResult(True); self.setResult(123); self.setResult(0.2135) # all of these work fine
Documenation says it accepts string also:
def OpenMayaUI.MPxContextCommand.setResult()
setResult() -> None
Set the value of the result to be returned by the command. The value can be
either a boolean, integer, floating point value, or string.
No matter how I pass string to this method (tried with simple string, with trailing comma, tuple with string inside, list with string inside, etc. - whatever crossed my mind), it just won’t accept any of it.
Am I missing something obvious (or not so obvious), or is it a bug?
Is there some work-around (to make it accept string; not a work-around to create {int: string} mapping, and return int (which I’m using at the moment), or similar solutions), if latter the case?
Thanks in advance!