Question

Is there a way I can modify this script which tries to fillet two lines and results in an error during the operation, and continue on through the script? The try exception didn't seem to work.

import maya.cmds as cmds

cmds.file(new=True, f=True)

# Create a circular fillet (by default) having radius 2.5 between the
# active curves:
a = cmds.curve(d=1, p=[(0, 0, 0), (0, 0, 5)] )
b = cmds.curve(d=1, p=[(0, 0, 5), (0, 0, 10)] )
c = cmds.curve(d=1, p=[(0, 0, 10), (-5, 0, 10)] )

allShapes = [a,b,c]

# do the first fillet
filletA = cmds.filletCurve(a,b, r=1.5 )
if cmds.objExists(filletA):
    allShapes.append(filletA)

# do the second fillet  
filletB = cmds.filletCurve(b,c, r=1.5 )  
if cmds.objExists(filletB):
    allShapes.append(filletB) 

print 'ran'
print allShapes

the error

# Warning: No curve contact point specified. Using start of curve instead. # 
# Warning: No curve contact point specified. Using start of curve instead. # 
# Warning: filletCurve1 (Fillet Curve): failed to get normal. # 
# Traceback (most recent call last):
#   File "<string>", line 12, in <module>
#   File "C:\\Users\\Martini\\Desktop\\trash\\fillet_01.py", line 14, in <module>
#     filletA = cmds.filletCurve(a,b, r=1.5 )
# # RuntimeError: Command filletCurve failed. Open Script Editor for details.
Était-ce utile?

La solution

Standard python try / except:

try: 
   #... do your stuff here...
except RuntimeError:
   #... continue here

limit your exception catching to ones you expect (in this case, RuntimeError is what Maya usually throws if a command fails) so you can get around Maya problems without hiding your errors.

Some general notes here:

Autres conseils

Also, it may be an error of maya update.

When you create an object or an attribute, sometimes maya won't refresh throught script.

As you can't use 'pause' to force refresh, you have to take the hard way and use : cmds.evalDeferred() command.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top