Exemplo n.º 1
0
def attributesToUINodes(col, attr_list, show_anm, show_stc, show_lck):
    """
    Convert a list of mmSolver API Attributes into classes to be used
    in the Solver UI.

    :param col: The Collection the Attributes belong to.
    :param col: Collection

    :param attr_list: List of Attributes to convert.
    :type attr_list: [Attribute, ..]

    :param show_anm: Should the animated attributes be visible?
    :type show_anm: bool

    :param show_stc: Should the static attributes be visible?
    :type show_stc: bool

    :param show_lck: Should the locked attributes be visible?
    :type show_lck: bool

    :returns: A hierarchy of UI nodes to be viewed in a 'tree view'.
    :rtype: PlugNode
    """
    root = attr_nodes.PlugNode('root')
    maya_nodes = dict()
    for attr in attr_list:
        attr_state = attr.get_state()
        is_animated = attr_state == mmapi.ATTR_STATE_ANIMATED
        is_static = attr_state == mmapi.ATTR_STATE_STATIC
        is_locked = attr_state == mmapi.ATTR_STATE_LOCKED
        if is_animated is True and show_anm is False:
            continue
        elif is_static is True and show_stc is False:
            continue
        elif is_locked is True and show_lck is False:
            continue
        full_name = attr.get_node(full_path=True)
        maya_node = maya_nodes.get(full_name)
        data = {'data': attr, 'collection': col}
        if maya_node is None:
            node_data = dict()
            # Add only the first attribute to the MayaNode
            # object. Other attributes will be added as they come up.
            node_data['data'] = [attr]
            short_name = full_name.rpartition('|')[-1]
            maya_node = attr_nodes.MayaNode(short_name,
                                            data=node_data,
                                            parent=root)
            maya_node.setNeverHasChildren(False)
            maya_nodes[full_name] = maya_node
        else:
            # Add subsequent attributes to the MayaNode object.
            node_data = maya_node.data()
            node_data['data'].append(attr)
            maya_node.setData(node_data)
        a = attr.get_attr()
        attr_node = attr_nodes.AttrNode(a, data=data, parent=maya_node)
        attr_node.setNeverHasChildren(True)
    return root
Exemplo n.º 2
0
def attributesToUINodes(attr_list):
    root = attr_nodes.PlugNode('root')
    maya_nodes = dict()
    for attr in attr_list:
        n = attr.get_node()
        a = attr.get_attr()
        maya_node = maya_nodes.get(n)
        if maya_node is None:
            data = {'data': None}
            maya_node = attr_nodes.MayaNode(n, data=data, parent=root)
            maya_nodes[n] = maya_node
        data = {'data': attr}
        attr_node = attr_nodes.AttrNode(a, data=data, parent=maya_node)
    return root
Exemplo n.º 3
0
def attributesToUINodes(col, attr_list, show_anm, show_stc, show_lck):
    """
    Convert a list of mmSolver API Attributes into classes to be used
    in the Solver UI.

    :param attr_list: List of Attributes to convert.
    :type attr_list: [Attribute, ..]

    :param show_anm: Should the animated attributes be visible?
    :type show_anm: bool

    :param show_stc: Should the static attributes be visible?
    :type show_stc: bool

    :param show_lck: Should the locked attributes be visible?
    :type show_lck: bool

    :returns: A hierarchy of UI nodes to be viewed in a 'tree view'.
    :rtype: PlugNode
    """
    root = attr_nodes.PlugNode('root')
    maya_nodes = dict()
    for attr in attr_list:
        n = attr.get_node()
        if attr.is_animated() is True and show_anm is False:
            continue
        elif attr.is_static() is True and show_stc is False:
            continue
        elif attr.is_locked() is True and show_lck is False:
            continue
        maya_node = maya_nodes.get(n)
        data = {'data': attr, 'collection': col}
        if maya_node is None:
            uuid = attr.get_node_uid()
            node_data = dict()
            # Add the first attribute to the MayaNode object.
            node_data['data'] = [attr]
            node_data['uuid'] = uuid
            maya_node = attr_nodes.MayaNode(n, data=node_data, parent=root)
            maya_nodes[n] = maya_node
        else:
            # Add subsequent attributes to the MayaNode object.
            node_data = maya_node.data()
            node_data['data'].append(attr)
            maya_node.setData(node_data)
        a = attr.get_attr()
        attr_node = attr_nodes.AttrNode(a, data=data, parent=maya_node)
    return root
Exemplo n.º 4
0
def attributesToUINodes(attr_list, show_anm, show_stc, show_lck):
    """
    Convert a list of mmSolver API Attributes into classes to be used
    in the Solver UI.

    :param attr_list: List of Attributes to convert.
    :type attr_list: [Attribute, ..]

    :param show_anm: Should the animated attributes be visible?
    :type show_anm: bool

    :param show_stc: Should the static attributes be visible?
    :type show_stc: bool

    :param show_lck: Should the locked attributes be visible?
    :type show_lck: bool

    :returns: A hierarchy of UI nodes to be viewed in a 'tree view'.
    :rtype: PlugNode
    """
    root = attr_nodes.PlugNode('root')
    maya_nodes = dict()
    for attr in attr_list:
        n = attr.get_node()
        if attr.is_animated() is True and show_anm is False:
            continue
        elif attr.is_static() is True and show_stc is False:
            continue
        elif attr.is_locked() is True and show_lck is False:
            continue
        maya_node = maya_nodes.get(n)
        data = {'data': attr}
        if maya_node is None:
            maya_node = attr_nodes.MayaNode(n, data=data, parent=root)
            maya_nodes[n] = maya_node
        a = attr.get_attr()
        attr_node = attr_nodes.AttrNode(a, data=data, parent=maya_node)
    return root
def attributesToUINodes(attr_list):
    """
    Convert a list of mmSolver API Attributes into classes to be used
    in the Solver UI.

    :param attr_list: List of Attributes to convert.
    :type attr_list: [Attribute, ..]

    :returns: A hierarchy of UI nodes to be viewed in a 'tree view'.
    :rtype: PlugNode
    """
    root = attr_nodes.PlugNode('root')
    maya_nodes = dict()
    for attr in attr_list:
        n = attr.get_node()
        maya_node = maya_nodes.get(n)
        data = {'data': attr}
        if maya_node is None:
            maya_node = attr_nodes.MayaNode(n, data=data, parent=root)
            maya_nodes[n] = maya_node
        a = attr.get_attr()
        attr_node = attr_nodes.AttrNode(a, data=data, parent=maya_node)
    return root