【发布时间】:2021-10-30 01:38:17
【问题描述】:
我可以找到另一个专门解决此问题的地方,但它似乎更加个人化,the other thread 没有提供任何帮助。这是错误:
# Error: Maya command error
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# File "<maya console>", line 26, in createJoints
# RuntimeError: Maya command error #
下面是代码,沿预制曲线创建关节链:
import maya.cmds as mc
##UI##
jointCurve = mc.window(title = "Create Joint Chain") #window title#
mc.rowColumnLayout(nc = 2) #divides window into two columns#
mc.text(l = "Number of Joints") #dialog prompt#
jntAmount = mc.intField (v = 5, min = 2) #default value of 5, minimum value of 2 joints#
mc.button(l = "Create", w = 150, c = "createJoints()") #confirms entry#
mc.button(l = "Cancel", w = 150, c = "mc.deleteUI(jointCurve)") #closes window, deletes UI#
mc.showWindow() #now that all parameters are defined, the window is opened#
##Method##
def createJoints():
#Gathering Information#
selCurve = mc.ls(sl = True) [0]
jointAmount = mc.intField(jntAmount, q = True, v = True)
prevJnt = ""
rootJnt = ""
for i in range(0, jointAmount): #for each increment from 0 to the amount defined in the field,#
mc.select(cl = True) #clear the selection,#
newJnt = mc.joint() #create a joint,#
motionPath = mc.pathAnimation(newJnt, c = selCurve, fractionMode = True) #affix to curve using a motion path,#
mc.cutKey(motionPath + ".u", time = ()) #remove animation keys from joint's U value (position on curve),#
mc.setAttr(motionPath + ".u", i * (1.0/(jointAmount - 1))) #distribute joints evenly along curve#
#delete motion path#
mc.delete(newJnt + ".tx", icn = True)#deletes x translate value's input connections#
mc.delete(newJnt + ".ty", icn = True)#deletes y translate value's input connections#
mc.delete(newJnt + ".tz", icn = True)#deletes z translate value's input connections#
mc.delete(motionPath) #deletes motion path itself#
if i == 0:
prevJnt = newJnt
rootJnt = newJnt
continue #skips next instructions for root joint since it has no parent#
mc.parent(newJnt, prevJnt) #parents current joint to previous joint#
prevJnt = newJnt #sets status of "previous" joint to current joint#
mc.joint(rootJnt, e = True, oj = "xyz", sao = "yup", ch = True, zso = True) #orients joints along chain#
mc.deleteUI(jointCurve) #closes prompt window#
每当我在新文件中运行代码时,它都能完美运行,没有问题。
但是我有另一个文件,当我运行此代码时,它会引发上述错误。
所以看起来它在导入 Maya 命令时遇到了问题? 以及这一行,特别是:
mc.cutKey(motionPath + ".u", time = ())
由于某种原因,即使我启动一个新文件并将另一个文件导入到场景中,也会引发此错误。
我完全不知道从哪里开始寻找..
【问题讨论】: