예제 #1
0
def orient():
    """
    Orients shell to closest 90 degree angle on selection.
    """
    s = mampy.ordered_selection(fl=True)
    if not s:
        return logger.warn('Nothing selected.')

    if s[0].is_map():
        new, current = SelectionList(), list(s)
        print current
        for pair in grouped(current, 2):
            new.append(MeshMap(pair))
        s = new

    for comp in s.itercomps():

        if not comp.is_map():
            comp = comp.to_map()
        if len(comp) > 2:
            logger.warn('Does not support border edges or multiple selections.')
            continue

        line = Line2D(*comp.points)
        shell = comp.get_uv_shell()
        shell.translate(a=line.angle, pu=line.center.u, pv=line.center.v)
예제 #2
0
def bake_pivot():
    """
    Bake modified manipulator pivot onto object.
    """
    s = mampy.ordered_selection(tr=True, l=True)
    dag = s.pop(len(s) - 1)
    out_idx = get_outliner_index(dag)
    parent = dag.get_parent()

    # Get manipulator information
    pos = cmds.manipMoveContext('Move', q=True, p=True)
    rot = cmds.manipMoveContext('Move', q=True, oa=True)
    rot = tuple(math.degrees(i) for i in rot)

    # Create dummpy parent
    space_locator = cmds.spaceLocator(name='bake_dummy_loc', p=pos)[0]
    cmds.xform(space_locator, cp=True)
    cmds.xform(space_locator, rotation=rot, ws=True)

    dag.set_parent(space_locator)
    cmds.makeIdentity(dag.name, rotate=True, translate=True, apply=True)

    dag.set_parent(parent)
    cmds.delete(space_locator)
    cmds.reorder(dag.name, f=True); cmds.reorder(dag.name, r=out_idx)
    cmds.select(list(s), r=True); cmds.select(dag.name, add=True)
예제 #3
0
 def slist(self):
     if self._slist is None:
         if self.add:
             self._slist = mampy.ordered_selection(-1)
         else:
             self._slist = mampy.selected()
         if not self._slist:
             raise TypeError('Invalid selection, select mesh face.')
     return self._slist
예제 #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)