Example #1
0
def get_outliner_index(dagnode):
    """
    Return the current index of the given node in the outliner.
    """
    if dagnode.is_root():
        return mampy.ls(l=True, assemblies=True).index(dagnode.name)
    else:
        outliner = mampy.ls(dag=True, tr=True, l=True)
        parent = dagnode.get_parent()
        return outliner.index(dagnode.name) - outliner.index(parent.name)
Example #2
0
def get_shells(components=None):
    """
    Collect selected uv shells.
    """
    s = components or mampy.selected()
    if not s:
        h = mampy.ls(hl=True)
        if not h:
            return logger.warn('Nothing selected.')
        s.extend(h)

    shells = SelectionList()
    for c in s.itercomps():
        if not c:
            c = MeshMap(c.dagpath).get_complete()
        else:
            c = c.to_map()

        count, array = c.mesh.getUvShellsIds()
        if c.is_complete():
            wanted = set(xrange(count))
        else:
            wanted = set([array[idx] for idx in c.indices])

        for each in wanted:
            shell = MeshMap.create(c.dagpath)
            shell.add([idx for idx, num in enumerate(array) if num == each])
            shells.append(shell)
    return list(shells.itercomps())
Example #3
0
def set_pivot(vector=(0, 0, 0)):
    vec = api.MVector(vector)
    for each in mampy.ls(sl=True, tr=True, l=True).iterdags():
        try:
            each.get_transform().set_pivot(vec)
        except RuntimeError():
            raise mampy.InvalidSelection('{} is not valid for function.'
                                         .format(each.typestr))
Example #4
0
def match_pivot_to_object():
    """
    Match secondary selection pivots to first object selected.
    """
    s, hl = mampy.ordered_selection(tr=True, l=True), mampy.ls(hl=True)
    if len(s) == 0:
        if len(hl) > 0:
            s = hl
        else:
            return logger.warn('Nothing Selected.')

    # check driver information
    dag = s.pop(0)
    trns = dag.get_transform()
    piv = trns.get_scale_pivot()

    # set pivot for driven objects
    for each in s.iterdags():
        print each, type(each)
        trns = each.get_transform().set_pivot(piv)