ml_utilities.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:ml_tools 作者: morganloomis 项目源码 文件源码
def constrain(source, destination, translate=True, rotate=True, scale=False):
    '''
    Constrain two objects, even if they have some locked attributes.
    '''

    transAttr = None
    rotAttr = None
    scaleAttr = None

    if translate:
        transAttr = mc.listAttr(destination, keyable=True, unlocked=True, string='translate*')
    if rotate:
        rotAttr = mc.listAttr(destination, keyable=True, unlocked=True, string='rotate*')
    if scale:
        scaleAttr = mc.listAttr(destination, keyable=True, unlocked=True, string='scale*')

    rotSkip = list()
    transSkip = list()

    for axis in ['x','y','z']:
        if transAttr and not 'translate'+axis.upper() in transAttr:
            transSkip.append(axis)
        if rotAttr and not 'rotate'+axis.upper() in rotAttr:
            rotSkip.append(axis)

    if not transSkip:
        transSkip = 'none'
    if not rotSkip:
        rotSkip = 'none'

    constraints = list()
    if rotAttr and transAttr and rotSkip == 'none' and transSkip == 'none':
        constraints.append(mc.parentConstraint(source, destination))
    else:
        if transAttr:
            constraints.append(mc.pointConstraint(source, destination, skip=transSkip))
        if rotAttr:
            constraints.append(mc.orientConstraint(source, destination, skip=rotSkip))

    return constraints
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号