Python Maya,动态约束 将maya.cmds作为cmds导入 将maya.mel导入为mel 输入数学 def区(a、b): 返回math.sqrt(math.pow(a[0]-b[0],2)+math.pow(a[1]-b[1],2)+math.pow(a[

Python Maya,动态约束 将maya.cmds作为cmds导入 将maya.mel导入为mel 输入数学 def区(a、b): 返回math.sqrt(math.pow(a[0]-b[0],2)+math.pow(a[1]-b[1],2)+math.pow(a[,python,maya,Python,Maya,Maya,动态约束 将maya.cmds作为cmds导入 将maya.mel导入为mel 输入数学 def区(a、b): 返回math.sqrt(math.pow(a[0]-b[0],2)+math.pow(a[1]-b[1],2)+math.pow(a[2]-b[2],2)) 对于范围(1,50)内的i: cmds.currentTime(一) a=cmds.nParticle('nParticle1',id=0,q=1,attribute='position') b=cmds.nPartic

Maya,动态约束
将maya.cmds作为cmds导入
将maya.mel导入为mel
输入数学
def区(a、b):
返回math.sqrt(math.pow(a[0]-b[0],2)+math.pow(a[1]-b[1],2)+math.pow(a[2]-b[2],2))
对于范围(1,50)内的i:
cmds.currentTime(一)
a=cmds.nParticle('nParticle1',id=0,q=1,attribute='position')
b=cmds.nParticle('nParticle2',id=0,q=1,attribute='position')

如果距离(a,b),为什么不在开始之前创建约束,然后设置一个基于距离启用约束的表达式?您好,谢谢。但它只适用于第1帧。我查过了。
import maya.cmds as cmds
import maya.mel as mel
import math
def dist(a,b):
    return math.sqrt(math.pow(a[0]-b[0],2)+math.pow(a[1]-b[1],2)+math.pow(a[2]-b[2],2))
for i in range (1,50):
    cmds.currentTime(i)
    a=cmds.nParticle('nParticle1',id=0,q=1,attribute='position')
    b=cmds.nParticle('nParticle2',id=0,q=1,attribute='position')
    if dist(a,b)<1:
        cmds.select('nParticle1.pt[0]',tgl=True)
        cmds.select('nParticle2.pt[0]',tgl=True)
        mel.eval('createNConstraint pointTopoint 0;')
        break