Catching Maya's internal Error / add blendShape target not working

165 zobrazení
Přeskočit na první nepřečtenou zprávu

Enrico Losavio

nepřečteno,
13. 10. 2016 12:18:0813.10.16
komu: Python Programming for Autodesk Maya
Hi everyone,

I apologize in advance for not having a clear subject for this topic, but in this case I believe the two things are strictly related...

I'm having a huge problem adding new targets on a blendShape node.
Every time I try to add a new target to one of my blendShape nodes, it fails and gives me this error:
# Error: line 1: Specified blendShape not found in history of baseShape. #

After researching for a few days, I've found out that the problem actually happens only when using a parallelBlender.
It seems as if Maya is not able to find a relationship between the base mesh and the blendShape nodes beyond the parallelBlender.








So I jumped into the GroupId/GroupParts/Set jungle and I checked all the connections, but they were right.
I tried using maya.cmds, maya api's' (MFnBlendShape.addTarget()), pymel, but none seem to work.

So I decided to take a more 'hacky' approach and wrote a function that temporarily connect the node I want directly to the 'baseShape', add the target (it works!!) and then restore the original connections.
I'm happy with the result, but I wanted this function to be fired off only when the normal blendShape.addTarget() doesn't work.
The easiest way of doing this is to 
try:
    bs_node
.addTarget('baseShape', 1, 'targetShape', 1)
except:
   
my_add_target(bs_node, attr_name)

Problem is: it doesn't work. When I run this code I still get the same error in the script editor. The error is not recognized as such by Python, thus not caught by the 'except'. Moreover, the execution of the script keeps going: if you add a print statement after the addTarget, it will be printed in the log!
Apparently there's a MEL 'catch' and 'catchQuiet' command supposed to catch Maya errors, but is not available for Python (and not embedded into the maya.mel module).
Has anyone had a similar situation? It's so frustrating when things just don't work the way they should after you tried everything...

So, summing up:
- i believe the two topics are strictly related, cause if I try to catch a normal cmds.error, it is caught regularly
- is there a non hacky solution that you know of, to solve the addTarget problem?
- what is the proper way to catch an internal Maya Error (which is not a Python Exception)?

Any help is greatly appreciated!
Thanks,

Enrico
Odpovědět všem
Odpověď autorovi
Přeposlat
0 nových zpráv