I removed the exception statement from:
self.__argData = OpenMaya.MArgDatabase(self.syntax(), args)
 
The test came up with the following error. 'n' should be an int.
 
-brian
 
cmds.test(n='d')
# Error: (kFailure): Unexpected Internal Failure
# Traceback (most recent call last):
#   File "G:/test.py", line 34, in doIt
#     self.__argData = OpenMaya.MArgDatabase(self.syntax(), args)
#   File "C:\engserv\rbuild\254\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py", line 1383, in __init__
# RuntimeError: (kFailure): Unexpected Internal Failure #
 
 
 
-------- Original Message --------
Subject: [Maya-Python Club:1775] Re: Error checking the arguments in a
custom Python API Command
From: Dean Edmonds <dean.edmo...@gmail.com>
Date: Sat, February 21, 2009 11:22 am
To: python_inside_maya@googlegroups.com


On Fri, Feb 20, 2009 at 17:31, <br...@meljunky.com> wrote:
> Trying to have better error checking for a custom Maya API Command:
>
> If you messed the argument types in a Python command from Maya.cmds it tells
> you what is wrong.
> For example:
> cmds.xform('nurbsSphere1', t=('spam','spam',1) )
> Results:
> # TypeError: Invalid arguments for flag 't'. Expected ( distance, distance,
> distance ), got ( str, str, int ) #
>
> In my custom command the MArgDatabase returns an exception when I butcher
> the argument type:
[...]
> Sure, the exception will stop the command from working but the user will not
> know why. Can this be done in Python?

MArgDatabase should print out an information message for you. Perhaps
you've failed to notice it because of the exception?

You should be able to just trap the exception and return. If you do
that and still don't see an informative error msg, let me know.

--
-deane


--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---

Reply via email to