I believe you have to format the command into a mel formatted string
you are doing it in your commented out version but not in your running code

'python("import qdTools;%s")' % repeat_command


On Fri, May 22, 2015 at 7:24 AM, Rémi Deletrain <[email protected]>
wrote:

> hi everyone,
>
> I try to make a decorator to add a command in the "repeatlast" python maya
> command.
>
> Only every time it returns me an error :
> // Error: Line 2.91: Invalid use of Maya object "False". //
>
>
> So I would try to do the same command but mel and it works.
> But! the decorator needs a language Python and when I repeat command (G
> key) I have an error message.
> I can shunt the problem with a try / except but I think it's not very
> clean. I would like to run the Python command.
>
> Here is my code:
>
> def repeat_command(function):
>     def wrapper(*args, **kwargs):
>
>         modules = ''
>         arguments = args
>         if [x for x in ['cls', 'self'] if x in 
> function.func_code.co_varnames]:
>             arguments = args[1:]
>             modules = '%s.' % args[0]
>
>
>         args_string = ''
>         if args:
>             for each in arguments:
>                 args_string = '%s, ' % each
>
>
>         kwargs_string = ''
>         if kwargs:
>             for key, item in kwargs.iteritems():
>                 kwargs_string = '%s=%s, ' % (key, item)
>
>
>         ret = function(*args, **kwargs)
>
>
>         repeat_command = '%s%s(%s%s)' % (modules, function.__name__, 
> args_string, kwargs_string)
>         if not args_string == '' and not kwargs_string == '':
>             repeat_command = '%s%s(%s, %s)' % (modules, function.__name__, 
> args_string, kwargs_string)
>
>         pmc.repeatLast(addCommand='import qdTools\n%s\n' % repeat_command, 
> addCommandLabel='qdCommand')
>         # try:
>         #     pm.callLastCommand('python("import qdTools;%s")' % 
> repeat_command)
>         # except:
>         #     pass
>
>
>
>         return ret
>     return wrapper
>
>
>
> Any one have idea?
>
> --
> 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/16534d51-4209-4ce5-882f-2b8dbf976d38%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/16534d51-4209-4ce5-882f-2b8dbf976d38%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/CAM9RXo%2Bsrahsd6rXyuD8y7WvVu-By_f9xUyFTW8H32r4tknmug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to