5月份Python的Raname脚本

2024-10-04 07:34:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我有这个脚本,我想父控件一起重命名图标。现在它命名组,但不命名控件或它们的父级。有人能帮我吗?你知道吗

def priming(*args):
    jointChain = pm.ls(sl = True, dag = True)
    jointChain.pop(-1)

    ori = raw_input()
    systemName = raw_input()
    suffix = "prime"

    prime1Name = "{0}_{1}_00_{2}1".format(ori, systemName, suffix)
    prime2Name = "{0}_{1}_00_{2}2".format(ori, systemName, suffix)

    pm.select(cl = True)

    for jointName in jointChain:

        primeIcon = pm.circle(nr = [1, 0, 0])

        groupOne = pm.group(em = True, n = prime1Name)  
        groupTwo = pm.group(em = True, n = prime2Name)

        pm.parent(groupTwo, groupOne)

        pm.parent(primeIcon, groupTwo)

        tempConstraint = pm.parentConstraint(jointName, groupOne, mo = False)

        pm.delete(tempConstraint)

        pm.makeIdentity(primeIcon, a = True, t = 1, r = 1, s = 1)

        tempConstraintTwo = pm.orientConstraint(primeIcon, jointName, mo = True)

Tags: trueinputrawsuffix命名控件pmgroupone
1条回答
网友
1楼 · 发布于 2024-10-04 07:34:10

这是您的代码的修改版本。这是组和控制器的父级,还根据命名方案对它们进行命名(如果需要,可以调整命名方案):

def priming(*args):
    jointChain = pm.ls(sl=True, dag=True)
    print jointChain
    jointChain.pop(-1)
    print jointChain

    ori = raw_input()
    systemName = raw_input()
    suffix = "prime"

    prime1Name = "{0}_{1}_00_{2}1".format(ori, systemName, suffix)
    prime2Name = "{0}_{1}_00_{2}2".format(ori, systemName, suffix)
    iconNameBase = "your_icon" # Your icon naming scheme here

    pm.select(cl=True)

    last_created_icon = None
    name_index = 1
    for jointName in jointChain:
        # Modify your iconName with every iteration here
        # Sample scheme: your_icon_1, your_icon_2 etc.
        iconName = "%s_%i" % (iconNameBase, name_index)
        name_index += 1
        primeIcon = pm.circle(nr=[1, 0, 0], n=iconName)
        groupOne = pm.group(em=True, n=prime1Name)  
        groupTwo = pm.group(em=True, n=prime2Name)
        pm.parent(groupTwo, groupOne)
        pm.parent(primeIcon, groupTwo)
        tempConstraint = pm.parentConstraint(jointName, groupOne, mo=False)
        pm.delete(tempConstraint)
        pm.makeIdentity(primeIcon, a=True, t=True, r=True, s=True)
        tempConstraintTwo = pm.orientConstraint(primeIcon, jointName, mo=True)

        if last_created_icon:
            pm.parent(groupOne, last_created_icon)

        last_created_icon = primeIcon

相关问题 更多 >