我在python中有这段代码:
"{0}.currentTime += 1;".format(hairSyst)
wherehairSyst
是前面定义的字符串。我不明白为什么会出现语法错误。我的目的是在maya中设置一个表达式,表达式有点长,我把整个东西贴在下面,也许你可以提出一个更好的方法。
expr = ("if ({0}.autoOverlap == 1){".format(firstControl.getName())
"{0}.currentTime += 1;".format(hairSyst)
"{0}.currentTime += 1;".format(nucleus)
"float $refresh_tx = {0}.translateX;".format(cube)
"float $refresh_ty = {0}.translateY;".format(cube)
"float $refresh_tz = {0}.translateZ;".format(cube)
"float $refresh_rx = {0}.rotateX;".format(cube)
"float $refresh_ry = {0}.rotateY;".format(cube)
"float $refresh_rz = {0}.rotateZ;".format(cube)
"}else if({0}.autoOverlap == 0){".format(firstControl.getName())
"{0}.currentTime = 1;".format(hairSyst)
"{0}.currentTime = 1;".format(nucleus)
"}"
)