예제 #1
0
def rotateSelectedOrientsAroundAxis(axis,
                                    degrees=90,
                                    preserveChildren=True,
                                    preserveShapes=True,
                                    syncJointAxes=True):
    """
    Rotate the selected nodes around the given axis
    If the node is a joint, its jointOrient will be rotated

    Args:
        axis:
        degress:
        preserveChildren:
        preserveShapes:
        syncJointAxes (bool): If True, joints will also have their
            translate and scale axes updated to match the new orientation
    """
    # if currently on move tool, make sure its object space
    if pm.currentCtx() == pm.melGlobals['$gMove']:
        pm.manipMoveContext('Move', e=True, mode=0)

    rotation = pm.dt.Vector()
    rotation[axis] = degrees

    nodes = pm.selected()
    for node in nodes:
        rotateOrientOrTransform(node, rotation, preserveChildren,
                                preserveShapes, syncJointAxes)
예제 #2
0
def get_manipulator_orientation():
    """This is a cheat until I find a better way to calculate the plane"""

    # Store original manipulator mode setting
    orig_mode = pymel.manipMoveContext('Move', query=True, mode=True)

    # Set manipulator to 'Component'
    pymel.manipMoveContext('Move', edit=True, mode=9)

    # Get manipulator Orientation
    orientation = pymel.manipMoveContext('Move', query=True, orientAxes=True)

    loc = pymel.spaceLocator(name='orientation')
    loc.setRotation([
        pymel.util.degrees(orientation[0]),
        pymel.util.degrees(orientation[1]),
        pymel.util.degrees(orientation[2])
    ])

    # loc_b = pymel.spaceLocator(name='normal')
    # loc_b.setTranslation(loc.getMatrix()[0][0:3])

    values = loc.getMatrix()[0][0:3]
    pymel.delete(loc)

    return OpenMaya.MVector(values[0], values[1], values[2])
예제 #3
0
def cycleMoveMode():
    """Cycle movement modes of the Move Tool (Object, Local, World)"""

    mode = pm.manipMoveContext( 'Move', query=True, mode=True )
    newMode = (mode+1)%3
    pm.manipMoveContext( 'Move', edit=True, mode=newMode )

    mel.MoveTool()

    print "// Move Tool: %s //" % ("Object", "Local", "World")[newMode]
예제 #4
0
def loc_edgeLoop():
    sel = pm.ls(sl=True,fl=True)
    index=1
    for obj in sel:
        transform = obj
        if isinstance(obj,pm.MeshEdge):
            transform = obj.node().getParent()
            pm.polySelect(transform,elb=obj.indices()[0])
            edgeLoop=pm.ls(sl=True)
        pm.language.melGlobals.initVar( 'string', 'gMove' )
        pm.setToolTo(pm.language.melGlobals['gMove'])
        moveManip = pm.manipMoveContext('Move', q=True,p=True)
        grpName = transform+'_ELP_LOC_GRP'
        if pm.objExists(grpName):
            elp_grp=pm.PyNode(grpName)
            print 'addingIndex'
            index+=1
        else:
            print 'removing index'
            index=1
            elp_grp = pm.group(em=True,n=grpName)
        locName=transform+'_'+str(index)+'_LOC'
        loc = pm.spaceLocator(n=locName)
        loc.translate.set(moveManip)
        loc.setParent(elp_grp)
        pm.select(edgeLoop, r=True)
예제 #5
0
def setTransformManipulatorMode(mode):
    context = pymel.currentCtx()

    if context == 'RotateSuperContext':
        if mode == 'world': mode = 1
        elif mode == 'local': mode = 0
        elif mode == 'trueValues': mode = 2

        pymel.manipRotateContext('Rotate', edit=True, mode=mode)

    elif context == 'moveSuperContext':
        if mode == 'world': mode = 2
        elif mode == 'local': mode = 0
        elif mode == 'trueValues': mode = 1

        pymel.manipMoveContext('Move', edit=True, mode=mode)

    elif context == 'scaleSuperContext':
        if mode == 'world': mode = 0
        elif mode == 'local': mode = 0
        elif mode == 'trueValues': mode = 0

        pymel.manipScaleContext('Scale', edit=True, mode=mode)
예제 #6
0
파일: util.py 프로젝트: MongoWobbler/piper
def getManipulatorPosition(transform):
    """
    Gets position of move manipulator where control is.

    Args:
        transform (string, PyNode, list, tuple, or set): Name of object(s) to get position from.

    Returns:
        (list): [x, y, z], World position of object in three coordinates.
    """
    pm.select(transform)
    pm.setToolTo('Move')
    position = pm.manipMoveContext('Move', q=1, p=1)
    pm.select(clear=True)
    return position
예제 #7
0
def getPosition(transform):
    """
    Gets position of move manipulator where control is.

    Args:
        transform (string): name of object to get position from.

    Returns:
        (list): [x, y, z], world position of object in three coordinates.
    """
    pm.select(transform)
    pm.setToolTo('Move')
    pos = pm.manipMoveContext('Move', q=1, p=1)
    pm.select(clear=True)
    return pos
예제 #8
0
def placeSine(sineTool, cntrlList):

    tempGrp = pm.group(pm.parent(pm.duplicate(cntrlList), w=True))

    pm.setToolTo('Move')
    pos = pm.manipMoveContext('Move', q=1, p=1)

    pm.delete(tempGrp)
    pm.select(clear=True)

    pm.move(sineTool, pos)

    distanceNum = getDistance(cntrlList[0], cntrlList[-1])

    sineTool.scale.set([distanceNum, distanceNum, distanceNum])

    pm.aimConstraint(cntrlList[-1], sineTool)
    pm.delete(pm.listRelatives(sineTool, type='aimConstraint'))

    return distanceNum
예제 #9
0
파일: util.py 프로젝트: MongoWobbler/piper
def cycleManipulatorSpace():
    """
    Cycles through the different manipulator spaces. Usually parent, world, and object.
    """
    validateSelect()
    current_context = pm.currentCtx()
    context_title = pm.contextInfo(current_context, t=True)

    if 'Move' in context_title:
        context_mode = pm.manipMoveContext('Move', q=True, mode=True)
        if context_mode == 0:
            pm.manipMoveContext('Move', edit=True, mode=context_mode + 1)
            pm.displayInfo('In Parent space.')
        elif context_mode == 1:
            pm.manipMoveContext('Move', edit=True, mode=context_mode + 1)
            pm.displayInfo('In World space.')
        else:
            pm.manipMoveContext('Move', edit=True, mode=0)
            pm.displayInfo('In Object space.')

    elif 'Rotate' in context_title:
        context_mode = pm.manipRotateContext('Rotate', q=True, mode=True)
        if context_mode == 0:
            pm.manipRotateContext('Rotate', edit=True, mode=context_mode + 1)
            pm.displayInfo('In World space.')
        elif context_mode == 1:
            pm.manipRotateContext('Rotate', edit=True, mode=context_mode + 1)
            pm.displayInfo('In Gimbal space.')
        else:
            pm.manipRotateContext('Rotate', edit=True, mode=0)
            pm.displayInfo('In Object space.')

    elif 'Scale' in context_title:
        context_mode = pm.manipScaleContext('Scale', q=True, mode=True)
        if context_mode == 0:
            pm.manipScaleContext('Scale', edit=True, mode=context_mode + 1)
            pm.displayInfo('In Parent space.')
        elif context_mode == 1:
            pm.manipScaleContext('Scale', edit=True, mode=context_mode + 1)
            pm.displayInfo('In World space.')
        else:
            pm.manipScaleContext('Scale', edit=True, mode=0)
            pm.displayInfo('In Object space.')