parentconstraint.py 文件源码

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

项目:cmt 作者: chadmv 项目源码 文件源码
def constraint_data(constraint):
    """Gets the parentConstraint data dictionary of the given constraint.

    The data dictionary can be used as input into the Component.
    :param constraint: Name of a parentConstraint node.
    :return: The parentConstraint data dictionary.
    """
    data = {
        'drivers': cmds.parentConstraint(constraint, q=True, targetList=True),
        'driven': cmds.listConnections('{0}.constraintParentInverseMatrix'.format(constraint), d=False)[0],
        'maintain_offset': False,
        'skip_tx': False,
        'skip_ty': False,
        'skip_tz': False,
        'skip_rx': False,
        'skip_ry': False,
        'skip_rz': False,
    }

    offset = cmds.getAttr('{0}.target[0].targetOffsetTranslate'.format(constraint))[0]
    offset += cmds.getAttr('{0}.target[0].targetOffsetRotate'.format(constraint))[0]
    for value in offset:
        if abs(value) > 0.000001:
            data['maintain_offset'] = True
            break
    for x in 'xyz':
        connection = cmds.listConnections('{0}.t{1}'.format(data['driven'], x), d=False)
        if not connection or connection[0] != constraint:
            data['skip_t{0}'.format(x)] = True

        connection = cmds.listConnections('{0}.r{1}'.format(data['driven'], x), d=False)
        if not connection or connection[0] != constraint:
            data['skip_r{0}'.format(x)] = True
    return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号