In Maya API 2.0 setResult() always returns a list to caller.
In python command I have self.setResult(0.5)
Then I call from mel script I receive [0.5]
$res=`getCustomPaintValue -1 4522`;
print("------- getCustomPaintValue1: " + $res + "\n");
I console I have error:
// Error: print("------- getCustomPaintValue1: " + $res + "\n");
// Error: Line 2.47: Illegal operation "+" on data of type float[].
I can use $res[0] in this command, but it doesn't work for other calls.
How can I return command result as float not a list?
Thanks.
On Thursday, June 20, 2019 at 7:22:36 PM UTC+3 Russel Rehmund wrote:
> Thank you!
>
>
> On Thursday, 20 June 2019 12:16:47 UTC-4, Ian Jones wrote:
>
>> Believe you are looking for self.setResult(cam)
>>
>> Set the value of the result to be returned by the command.
>>
>> *Name:* setResult(value)
>> *Parameters:* value - bool, int, float, string, sequence of numerics or
>> sequence of strings
>> *Returns:* None
>> *Description:* Set the value of the result to be returned by the command.
>>
>> On Thu, Jun 20, 2019, 9:11 AM Russel Rehmund <[email protected]> wrote:
>>
> Anyone know how to properly work this? Any examples or links to
>>> documentation would be appreciated.
>>>
>>> I'm trying to return a string from my command plugin, though I'm not
>>> even sure it's possible. The string is the name of a camera that I've
>>> created.
>>>
>>> I'd like to be able to do this:
>>>
>>> camera = cmds.my_command()
>>>
>>>
>>> Here's my initialize function:
>>>
>>> def initializePlugin(mobject):
>>> mplugin = omMPx.MFnPlugin(mobject, author, version, 'Any')
>>> try:
>>> cam = mplugin.registerCommand(kPluginCmdName, cmdCreator,
>>> syntaxCreator)
>>> log.info("Successfully registered plugin:
>>> {0}".format(kPluginCmdName))
>>> if cam:
>>> return cam
>>> except Exception as e:
>>> log.critical("Failed to register command:
>>> {0}".format(kPluginCmdName))
>>> log.critical(traceback.format_exc(e))
>>> raise
>>>
>>> My doIt function:
>>>
>>> def doIt(self, args):
>>> """ Command execution. """
>>> arg_data = om.MArgDatabase(self.syntax(), args)
>>>
>>> ... flags parsing
>>>
>>> # Run the turntable code here.
>>> cam = main(...)
>>> return cam
>>>
>>> Am I missing something here?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>>
>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to [email protected].
>>
>>
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/da684b50-5c6d-425c-a87b-e9f902ec0414%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/python_inside_maya/da684b50-5c6d-425c-a87b-e9f902ec0414%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/a9d86aae-9649-4f48-adb0-5deba4b68ad5n%40googlegroups.com.