Ejemplo n.º 1
0
def load():
    '''loads animation environment'''
    print "loading animation environment presets..."
    #set autoKey
    cmds.autoKeyframe( state=True )
    #set 24fps and playback on all viewports
    cmds.playbackOptions(ps=1.0, v='all')
    #set unlimited undo's
    cmds.undoInfo( state=True, infinity=True )
    #set manipulator sizes
    if lib.checkAboveVersion(2014):
        cmds.manipOptions( r=False, hs=55, ls=4, sph=1 )
    else:
        cmds.manipOptions( r=False, hs=55, ls=4 )
    #set framerate visibility
    mel.eval("setFrameRateVisibility(1);")
    #gimbal rotation
    cmds.manipRotateContext('Rotate', e=True, mode=2)
    #world translation
    cmds.manipMoveContext('Move', e=True, mode=2)
    #time slider height
    aPlayBackSliderPython = mel.eval('$tmpVar=$gPlayBackSlider')
    cmds.timeControl(aPlayBackSliderPython, h=45, e=True);
    #special tick color
    cmds.displayRGBColor("timeSliderTickDrawSpecial", 1,0.5,0)

    #check if hotkeys have been set
    if (cmds.hotkey( 't', ctl=True, query=True, name = True)== 'CharacterAnimationEditorNameCommand'):
        print "Hotkeys have been previously loaded"
    else:
        setHotkeys('default')

    print "ENVIRONMENT SET\n", #the comma forces output on the status line
Ejemplo n.º 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)
Ejemplo n.º 3
0
def captureManipPiv():
	mmc = cmds.manipMoveContext()
	cmds.setToolTo(mmc)
	manipLoc = cmds.manipMoveContext(mmc, q=True, p=True)
	rotObj = cmds.xform(q=True, ws=True, ro=True)
	posCopy = cmds.xform(q=True, ws=True, t=True)
	scaleCopy = cmds.xform(q=True, ws=True, s=True)
	manipPos = []
	transObj = []
	scaleObj = []
	if manipLoc:
		for num in manipLoc:
		    numFloat = float(num)
		    numRound = round(numFloat,5)
		    manipPos.append(numRound)
		cmds.setToolTo('moveSuperContext')
		cmds.deleteUI(mmc)
		for trans in posCopy:
			posFloat = float(trans)
			posRound = round(posFloat,5)
			transObj.append(posRound)
		for scale in scaleCopy:
			scaleFloat = float(scale)
			scaleRound = round(scaleFloat,5)
			scaleObj.append(scaleRound)
		# insert field values
		cmds.floatFieldGrp('nwSAK_manipPivot',e=True,v1=manipPos[0],v2=manipPos[1],v3=manipPos[2])
		cmds.floatFieldGrp('nwSAK_transPivots',e=True,v1=transObj[0],v2=transObj[1],v3=transObj[2])
		cmds.floatFieldGrp('nwSAK_rotPivots',e=True,v1=rotObj[0],v2=rotObj[1],v3=rotObj[2])
		cmds.floatFieldGrp('nwSAK_scalePivots',e=True,v1=scaleObj[0],v2=scaleObj[1],v3=scaleObj[2])
	# line
	else:
		nmGUI_func.nmGUI_runCheck('error','No pivot object(s) selected')
Ejemplo n.º 4
0
def manipState(*args):
	localState = cmds.symbolCheckBox( selectBtn, q=True, value=True )
	# print("localState: %s" %localState)
	if( localState ):
		# Move tool in local mode
		cmds.manipMoveContext( "Move", e=1, mode=0 )
	else:
		# Move tool in world mode.
		cmds.manipMoveContext( "Move", e=1, mode=2 )
Ejemplo n.º 5
0
def transSett(*args):
	sttng = cmds.radioButtonGrp("transSetts", q=True, sl=True)
	
	if (sttng==1):
		trans = 1
	else:
		trans = 2
	
	cmds.manipMoveContext("Move", e=True, mode=trans)
Ejemplo n.º 6
0
def manipMoveToggle():
    '''Toggles the Translate Manip Context Through the useful modes'''
    try:
        if cmds.manipMoveContext('Move', q=1, mode=1) == 0:
            cmds.manipMoveContext('Move', e=1, mode=2)
        else:
            cmds.manipMoveContext('Move', e=1, mode=0)
    except Exception as e:
        print(e)
Ejemplo n.º 7
0
def transSett(*args):
	sttng = cmds.radioButtonGrp("transSetts", q=True, sl=True)
	
	if (sttng==1):
		trans = 1
	else:
		trans = 2
	
	cmds.manipMoveContext("Move", e=True, mode=trans)
Ejemplo n.º 8
0
def manipMoveToggle():
    '''Toggles the Translate Manip Context Through the useful modes'''
    try:
        if cmds.manipMoveContext('Move',q=1, mode=1 ) == 0:
            cmds.manipMoveContext('Move',e=1,mode=2)
        else:
            cmds.manipMoveContext('Move',e=1,mode=0)
    except Exception, e:
        print e
Ejemplo n.º 9
0
def hotMove():
	moveQuery = cmds.manipMoveContext('Move', q=True, mode=True) + 2
	if moveQuery > 2:
		moveQuery = 0
	if moveQuery == 0:
		moveName = 'object'
	elif moveQuery == 2:
		moveName = 'world'
	cmds.manipMoveContext('Move', edit=True, mode=moveQuery)
	cmds.headsUpMessage('Move: ' + moveName)
Ejemplo n.º 10
0
def HotKey_AxisSwitcher():
	# AxisSwitcher v2.1.0

	oPanel = cmds.getPanel(wf = True)
	if 'modelPanel' in oPanel: # if a viewport is acitve (Not graphEditor1/etc)
		oCamera = cmds.modelPanel(oPanel, query=True, camera=True).replace('Shape', '')


		iVal = cmds.manipMoveContext('Move', q = True, mode = True)

	if iVal == 1:
		cmds.manipMoveContext('Move', e = True, mode = 2)
		cmds.manipRotateContext('Rotate', e = True, mode = 1)
		aPrint = ['6bad64', 'WORLD', 0x6c756b] # Green
	elif iVal == 2:
		cmds.manipMoveContext('Move', e = True, mode = 0)
		cmds.manipRotateContext('Rotate', e = True, mode = 0)
		aPrint = ['d8766c', 'OBJECT', 0x756b6b] # Red
	elif iVal == 0:
		# Camera space Manipultor
		aCoordinate = cmds.xform(oCamera, q = True, a = True, ws = True, t = True)

		cmds.manipMoveContext('Move', e = True, mode = 6, activeHandle = 0, orientTowards = aCoordinate)
		cmds.manipRotateContext('Rotate', e = True, mode = 3)
		aPrint = ['9bbcf2', 'CAMERA', 0x485872] # Blue
	else:
		cmds.manipMoveContext('Move', e = True, mode = 1)
		cmds.manipRotateContext('Rotate', e = True, mode = 2)
		aPrint = ['a7a8af', 'LOCAL ', 0x6b6c75] # Gray

	cmds.inViewMessage(amg = '<text style="color:#%s";>%s</text>'%(aPrint[0], aPrint[1]), pos = 'botCenter', fade = True, fts = 7, ft = 'arial',bkc = aPrint[2] )
Ejemplo n.º 11
0
def set_movetool_direction(vx, vy, vz, horizontal=False):
    """Set moveTool's axes to match given vector"""
    rx, ry = vector_to_xy_euler_angles(vx, vy, vz)
    rz = 0
    if horizontal:
        rx = 0
    mc.manipMoveContext('Move',
                        edit=True,
                        mode=6,
                        orientAxes=[rx, ry, rz],
                        activeHandle=2)
Ejemplo n.º 12
0
def nmManipulator_world():
    '''
	this function will set all the transform tools to world space.
	'''
    cmds.manipMoveContext('Move', e=True, mode=2)
    cmds.manipRotateContext('Rotate', e=True, mode=1)
    try:
        cmds.manipScaleContext('Scale', e=True, mode=2)
    except:
        pass
    # line
    nmGUI_func.nmGUI_runCheck(
        'complete', 'Manipulator tools have been set to world space.')
Ejemplo n.º 13
0
def orientMoveManip():
    selection   = cmds.ls(selection=True)
    
    if len(selection) < 2: 
        cmds.warning("You need to select at least 2 objects.")
        return
    
    sourceObjs  = selection[0:-1]
    targetObj   = selection[-1]
    orient      = cmds.xform(targetObj, query=True, ws=True, rotation=True)
    orientRad   = [math.radians(loopDeg) for loopDeg in orient]
    cmds.manipMoveContext('Move', edit=True, mode=6, orientAxes=orientRad)
    cmds.select(sourceObjs, replace=True)
    cmds.setToolTo("Move")
Ejemplo n.º 14
0
def orientMoveManip():
    selection = cmds.ls(selection=True)

    if len(selection) < 2:
        cmds.warning("You need to select at least 2 objects.")
        return

    sourceObjs = selection[0:-1]
    targetObj = selection[-1]
    orient = cmds.xform(targetObj, query=True, ws=True, rotation=True)
    orientRad = [math.radians(loopDeg) for loopDeg in orient]
    cmds.manipMoveContext('Move', edit=True, mode=6, orientAxes=orientRad)
    cmds.select(sourceObjs, replace=True)
    cmds.setToolTo("Move")
Ejemplo n.º 15
0
def set_commands(node_type='transform', pre_func=str, post_func=str):
    mc.manipMoveContext('Move', e=True, preDragCommand=[pre_func, node_type])
    mc.manipMoveContext('Move', e=True, postDragCommand=[post_func, node_type])
    mc.manipRotateContext('Rotate',
                          e=True,
                          preDragCommand=[pre_func, node_type])
    mc.manipRotateContext('Rotate',
                          e=True,
                          postDragCommand=[post_func, node_type])
    mc.manipScaleContext('Scale', e=True, preDragCommand=[pre_func, node_type])
    mc.manipScaleContext('Scale',
                         e=True,
                         postDragCommand=[post_func, node_type])
    # the drag commands are only active on reentering the context
    mc.setToolTo(mc.currentCtx())
Ejemplo n.º 16
0
def snapTemplateToPivot():
    # Get selection
    selection = cmds.ls (sl=True)
    length = len(selection)
    
    # If statement to see if enough things were selected
    if length < 2:
        print "Not enough things selected to run script."
        
    else: 
        # First thing selected is controller
        thingA = selection[0] 
        
        # Second thing selected is the object/component you want to snap template to
        thingB = selection[1]
        
        # Get position of thingB
        cmds.select (thingB, r=True)
        cmds.setToolTo('moveSuperContext')
        tempLOC =  cmds.spaceLocator(p=cmds.manipMoveContext('Move', q=True, p=True), a=True)
        cmds.xform(cp=True)
        locPos = cmds.xform (tempLOC, q=True, rp=True, ws=True)
        
        # put thing A in the position of thing B
        cmds.move (locPos[0], locPos[1], locPos[2], thingA,  a=True, ws=True, rpr=True)
       
        # Delete temporary locator
        cmds.delete (tempLOC)
Ejemplo n.º 17
0
def setManipCommands(nodeType='transform', preFunc=str, postFunc=str):
    mc.manipMoveContext('Move', e=True, preDragCommand=[preFunc, nodeType])
    mc.manipMoveContext('Move', e=True, postDragCommand=[postFunc, nodeType])
    mc.manipRotateContext('Rotate', e=True, preDragCommand=[preFunc, nodeType])
    mc.manipRotateContext('Rotate',
                          e=True,
                          postDragCommand=[postFunc, nodeType])
    mc.manipScaleContext('Scale', e=True, preDragCommand=[preFunc, nodeType])
    mc.manipScaleContext('Scale', e=True, postDragCommand=[postFunc, nodeType])
    # the drag commands are only active on reentering the context
    currentCtx = mc.currentCtx()
    if currentCtx in [
            'moveSuperContext', 'RotateSuperContext', 'scaleSuperContext'
    ]:
        # only set context if needed
        mc.setToolTo(currentCtx)
def selectionAlign():
    # get the current selection
    selected = cmds.ls(selection=True, fl=True)
    if (len(selected) <= 1):
        print 'You must select at least two objects, one component + one target object'
        return
    # Extract the target object
    AttachObj = selected[-1]
    testObj = AttachObj.split('.')
    print testObj
    if (len(testObj) != 1):
        print 'The last selection must be an object'
        return
    del (selected[-1])
    # For each component, we will duplicate a target object and aligh the target with this component
    for curT in selected:
        print curT
        newSel = mc.select(curT)
        # get current position of the move manipulator
        pos = mc.manipMoveContext('Move', query=True, position=True)
        atObj = mc.duplicate(AttachObj)
        print atObj
        # We need to move target object to the center of selected component, then we can do normal constraint
        mc.move(pos[0], pos[1], pos[2], atObj)
        constr = cmds.normalConstraint(curT,
                                       atObj,
                                       aimVector=(1, 0, 0),
                                       worldUpType='object')
        mc.delete(constr)
Ejemplo n.º 19
0
 def makeLocOnSel(self):
     tool = cmds.currentCtx()
     cmds.setToolTo( 'moveSuperContext' )
     pos = cmds.manipMoveContext( 'Move', q=True, p=True )
     startLoc = cmds.spaceLocator (n = ('skinWrangler_jointBboxLocator'))[0]
     cmds.move(pos[0] ,pos[1] ,pos[2] ,startLoc, ws = 1 , a =1)
     cmds.setToolTo(tool)
     return startLoc
Ejemplo n.º 20
0
 def makeLocOnSel(self):
     tool = cmds.currentCtx()
     cmds.setToolTo('moveSuperContext')
     pos = cmds.manipMoveContext('Move', q=True, p=True)
     startLoc = cmds.spaceLocator(n=('skinWrangler_jointBboxLocator'))[0]
     cmds.move(pos[0], pos[1], pos[2], startLoc, ws=1, a=1)
     cmds.setToolTo(tool)
     return startLoc
Ejemplo n.º 21
0
def get_tool_pivot_position():
    """Get the current pivot from the move tool
    The current tool context is kept
    """
    current_tool = cmds.currentCtx()
    cmds.setToolTo("Move")
    position = cmds.manipMoveContext('Move', query=True, position=True)
    cmds.setToolTo(current_tool)
    return position
Ejemplo n.º 22
0
def setManip():

    manip = cmds.radioButtonGrp('manip', q=True, sl=True)

    # Setting to World Space
    if (manip == 1):
        cmds.manipMoveContext('Move', e=True, mode=2)
        cmds.manipRotateContext('Rotate', e=True, mode=1)
        cmds.manipScaleContext('Scale', e=True, mode=2)

    # Setting to Object Space
    elif (manip == 2):
        cmds.manipMoveContext('Move', e=True, mode=0)
        cmds.manipRotateContext('Rotate', e=True, mode=0)
        cmds.manipScaleContext('Scale', e=True, mode=0)

    maya.mel.eval('SelectToolOptionsMarkingMenu; MarkingMenuPopDown;'
                  )  # Changing Tool to selection
Ejemplo n.º 23
0
def toggleMoveMode():
    mov = cmds.manipMoveContext('Move', query=True, mode=True)

    # 0 = Local, 1 = Global, 2 = Gimbal
    if (mov == 0):
        cmds.manipMoveContext('Move', edit=True, mode=1)
    elif (mov == 1):
        cmds.manipMoveContext('Move', edit=True, mode=2)
    else:
        cmds.manipMoveContext('Move', edit=True, mode=0)
Ejemplo n.º 24
0
def toggleMoveMode():
    mov = cmds.manipMoveContext('Move', query=True, mode=True)
    
    # 0 = Local, 1 = Global, 2 = Gimbal
    if (mov == 0):
        cmds.manipMoveContext('Move', edit=True, mode=1)
    elif (mov == 1):
        cmds.manipMoveContext('Move', edit=True, mode=2)
    else:
        cmds.manipMoveContext('Move', edit=True, mode=0)
    def scriptJobCmds(self):

        mc.manipScaleContext('Scale', e=True, mode=6)
        mc.manipRotateContext('Rotate', e=True, mode=3)
        mc.manipMoveContext('Move', e=True, mode=6)

        #fix: isolateSelection
        viewSelectedSets = mc.ls('*ViewSelectedSet', type='objectSet')
        isolatedObjs = []
        panelName = ''

        for set in viewSelectedSets:
            isolatedObjs = mc.sets(set, q=True)

            if (len(isolatedObjs) == 0):
                continue

            panelName = set.split('ViewSelectedSet')[0]
            mc.isolateSelect(panelName, s=False)
            mc.isolateSelect(panelName, s=True)
            break
Ejemplo n.º 26
0
def softSelectionClusterWeights(*args):

    sel = mc.ls(sl=True, o=True)

    if not sel:
        raise RuntimeError('Please select some vertices.')

    weights = getSoftSelectionWeights()

    if not weights:
        raise RuntimeError('Please select some vertices.')

    #get manipulator position for pivot
    mc.setToolTo('Move')
    moveMode = mc.manipMoveContext('Move', query=True, mode=True)
    mc.manipMoveContext('Move', edit=True, mode=0)
    position = mc.manipMoveContext('Move', query=True, position=True)
    mc.manipMoveContext('Move', edit=True, mode=moveMode)

    clusterNode, clusterHandle = mc.cluster(sel[0])

    for vert in mc.ls(sel[0]+'.vtx[*]', fl=True, l=True):
        weight = 0.0
        if vert in weights.keys():
            weight = weights[vert]
        mc.percent(clusterNode, vert, v=weight)

    #set cluster pivot
    mc.xform(clusterHandle, a=True, ws=True, piv=(position[0], position[1], position[2]))
    clusterShape = mc.listRelatives(clusterHandle, c=True, s=True)
    mc.setAttr(clusterShape[0] + '.origin', position[0], position[1], position[2])
Ejemplo n.º 27
0
def softSelectionClusterWeights(*args):
    
    sel = mc.ls(sl=True, o=True)
    
    if not sel:
        raise RuntimeError('Please select some vertices.')

    weights = getSoftSelectionWeights()
    
    if not weights:
        raise RuntimeError('Please select some vertices.')
    
    #get manipulator position for pivot
    mc.setToolTo('Move')
    moveMode = mc.manipMoveContext('Move', query=True, mode=True)
    mc.manipMoveContext('Move', edit=True, mode=0)
    position = mc.manipMoveContext('Move', query=True, position=True)
    mc.manipMoveContext('Move', edit=True, mode=moveMode)

    clusterNode, clusterHandle = mc.cluster(sel[0])
    
    for vert in mc.ls(sel[0]+'.vtx[*]', fl=True, l=True):
        weight = 0.0
        if vert in weights.keys():
            weight = weights[vert]
        mc.percent(clusterNode, vert, v=weight)

    #set cluster pivot
    mc.xform(clusterHandle, a=True, ws=True, piv=(position[0], position[1], position[2]))
    clusterShape = mc.listRelatives(clusterHandle, c=True, s=True)
    mc.setAttr(clusterShape[0] + '.origin', position[0], position[1], position[2])    
Ejemplo n.º 28
0
def translateManip():
    mode = cmds.manipMoveContext('Move', q=True, mode=True)
    # print mode
    if mode == 0:
        cmds.manipMoveContext('Move', e=True, mode=1)
        message('Local')
    elif mode == 1:
        cmds.manipMoveContext('Move', e=True, mode=2)
        message('World')
    elif mode == 2:
        cmds.manipMoveContext('Move', e=True, mode=0)
        message('Object')
Ejemplo n.º 29
0
def manipMoveContext(*args, **kwargs):
    if len(args):
        doPassSelf = kwargs.pop('passSelf', False)
    else:
        doPassSelf = False
    for key in ['pod', 'postCommand', 'postDragCommand', 'prc', 'prd', 'preCommand', 'preDragCommand', 'psc']:
        try:
            cb = kwargs[key]
            if callable(cb):
                kwargs[key] = _factories.makeUICallback(cb, args, doPassSelf)
        except KeyError:
            pass
    res = cmds.manipMoveContext(*args, **kwargs)
    return res
Ejemplo n.º 30
0
def alignPivot(move = True, scale = False, fix = False):
    normal = getFaceNormals()

    if fix:
        up = pm.dt.Vector(0.0, 1.0, 0.0)
        if up == normal: up = pm.dt.Vector(1.0, 0.0, 0.0)

        y_axis = normal.cross(up)
        x_axis = y_axis.cross(normal)

        rot = computeFrame(normal, x_axis, y_axis)

    if move:
        if fix:
            cmds.manipMoveContext("Move", edit=True, mode=6, orientAxes=[rot[0], rot[1], rot[2]])
        else:
            cmds.manipMoveContext("Move", edit=True, mode=6, alignAlong=[normal.x, normal.y, normal.z])
    if scale:
        if fix:
            cmds.manipScaleContext("Scale", edit=True, mode=6, orientAxes=[rot[0], rot[1], rot[2]])
        else:
            cmds.manipScaleContext("Scale", edit=True, mode=6, alignAlong=[normal.x, normal.y, normal.z])
    cmds.refresh(currentView=True)
Ejemplo n.º 31
0
def softSelectToCluster(mesh, name):
    # Get the manipulator position for the selection
    cmds.setToolTo('Move')
    currentMoveMode = cmds.manipMoveContext('Move', query=True,
                                            mode=True)  #Get the original mode
    cmds.manipMoveContext('Move', edit=True, mode=0)  #set to the correct mode
    pos = cmds.manipMoveContext('Move', query=True,
                                position=True)  # get the position
    cmds.manipMoveContext('Move', edit=True, mode=currentMoveMode)  # and reset

    # Grab the soft selection values using the API
    selection = om.MSelectionList()
    ssel = om.MRichSelection()
    ssel.getSelection(selection)

    dagPath = om.MDagPath()
    component = om.MObject()

    vertIter = om.MItSelectionList(selection, om.MFn.kMeshVertComponent)
    elements, weights = [], []

    # TODO Be a bit more explicit here with the mesh, its shapeNode, and the dagPath
    # so we can make sure we don't have multiple meshes with verts selected

    softSel = {}
    while not vertIter.isDone():
        vertIter.getDagPath(dagPath, component)
        dagPath.pop()  #Grab the parent of the shape node
        node = dagPath.fullPathName()
        fnComp = om.MFnSingleIndexedComponent(component)
        getWeight = lambda i: fnComp.weight(i).influence(
        ) if fnComp.hasWeights() else 1.0

        for i in range(fnComp.elementCount()):
            softSel[fnComp.element(i)] = getWeight(i)
        vertIter.next()

    if not softSel:
        print "No Soft Selection"
        return

    # Build the Cluster and set the weights
    clusterNode, clusterHandle = cmds.cluster(mesh, name=name)
    vnum = cmds.polyEvaluate(mesh, vertex=1)
    weights = [softSel.get(i, 0.0) for i in range(vnum)]
    cmds.setAttr('{0}.weightList[0].weights[0:{1}]'.format(
        clusterNode, vnum - 1),
                 *weights,
                 size=vnum)

    # Reposition the cluster
    cmds.xform(clusterHandle, a=True, ws=True, piv=(pos[0], pos[1], pos[2]))
    clusterShape = cmds.listRelatives(clusterHandle,
                                      children=True,
                                      shapes=True)
    cmds.setAttr(clusterShape[0] + '.origin', pos[0], pos[1], pos[2])
def findFaces(mesh):
    faces = []
    faceCount = cmds.polyEvaluate(mesh, face=True)

    meshTransform = cmds.xform(mesh, query=True, matrix=True, worldSpace=True)

    for face in range(0, faceCount):
        faceName = mesh + ".f[" + str(face) + "]"
        vtxLst = cmds.polyInfo(faceName, faceToVertex=True)
        vtxIdx = str(vtxLst[0]).split()
        vtxIdx = vtxIdx[2:]
        """ Vertex positions """
        vtxA = cmds.getAttr(mesh + ".vt[" + vtxIdx[0] + "]")
        vtxB = cmds.getAttr(mesh + ".vt[" + vtxIdx[1] + "]")
        vtxC = cmds.getAttr(mesh + ".vt[" + vtxIdx[2] + "]")
        vtxD = cmds.getAttr(mesh + ".vt[" + vtxIdx[3] + "]")
        """ Make each vertex a list """
        vtxA = list(vtxA[0])
        vtxB = list(vtxB[0])
        vtxC = list(vtxC[0])
        vtxD = list(vtxD[0])
        """ Multiply verticies by transform matrix (convert to world space) """
        vtxA = matrixMult(meshTransform, vtxA)
        vtxB = matrixMult(meshTransform, vtxB)
        vtxC = matrixMult(meshTransform, vtxC)
        vtxD = matrixMult(meshTransform, vtxD)
        vertices = [vtxA, vtxB, vtxC, vtxD]
        normal = getNormal(vtxA, vtxB, vtxC)
        """ Getting center of the face by querying the position of the move manipulator """
        cmds.select(faceName)
        cmds.setToolTo('moveSuperContext')
        centerPos = cmds.manipMoveContext('Move', q=True, p=True)
        """ Get radius around center to place start/end point at """
        radius = [0.0, 0.0, 0.0]
        vecAB = convertToVec(vtxA, vtxB)
        vecAC = convertToVec(vtxA, vtxC)
        for axes in range(0, len(vecAB)):
            radius[axes] = ((vecAB[axes] + vecAC[axes]) / 2.0)

        faceInfo = {
            'normal': normal,
            'center': centerPos,
            'radius': radius,
            'vertices': vertices,
        }
        faces.append(faceInfo)
    return faces
Ejemplo n.º 33
0
def getManipulatorPosition():
    """
    Returns:
      list
    """
    cmds.setToolTo('Move')
    currentMoveMode = cmds.manipMoveContext('Move', q=True, m=True)
    cmds.manipMoveContext('Move', e=True, m=0)
    pos = cmds.manipMoveContext('Move', q=True, p=True)
    cmds.manipMoveContext('Move', e=True, m=currentMoveMode)
    return pos
Ejemplo n.º 34
0
def getManipulatorPosition():
    """
    Returns:
      list
    """
    cmds.setToolTo('Move')
    currentMoveMode = cmds.manipMoveContext('Move', q=True, m=True)
    cmds.manipMoveContext('Move', e=True, m=0)
    pos = cmds.manipMoveContext('Move', q=True, p=True)
    cmds.manipMoveContext('Move', e=True, m=currentMoveMode)
    return pos
Ejemplo n.º 35
0
def center_selection_manip():
    """Locator created at position of "Move" manipulator of selected"""
    sel = cmds.ls(selection=True)

    if sel:
        cmds.setToolTo('Move')
        cntr_pos = cmds.manipMoveContext('Move', q=True, p=True)

        loc = cmds.spaceLocator(p=[0, 0, 0])
        cmds.setAttr(loc[0] + '.translate', cntr_pos[0], cntr_pos[1],
                     cntr_pos[2])

        LOG.info(
            'Created locators at manipulator center of selected positions.')
        return loc[0]

    else:
        LOG.error('Nothing selected!')
Ejemplo n.º 36
0
	def moveTool(self):
		try:
			if Cache.keyOffset == 0:
				cmds.manipMoveContext('myMove', edit = True, mode = 2 ) # world mode
				Cache.currentContext = 'myMove'
				self.setAttributes()
			else:
				cmds.manipMoveContext('myMove', edit = True, mode = 0 ) # object mode
				Cache.currentContext = 'myMove'
				self.setAttributes()
		except:
			if Cache.keyOffset == 0:
				cmds.manipMoveContext( 'myMove', mode = 2 ) # world mode
				Cache.currentContext = 'myMove'
				self.setAttributes()
			else:
				cmds.manipMoveContext('myMove', mode = 0 ) # object mode
				Cache.currentContext = 'myMove'
				self.setAttributes()
		cmds.setToolTo( Cache.currentContext )
Ejemplo n.º 37
0
 def moveTool(self):
     try:
         if Cache.keyOffset == 0:
             cmds.manipMoveContext('myMove', edit=True,
                                   mode=2)  # world mode
             Cache.currentContext = 'myMove'
             self.setAttributes()
         else:
             cmds.manipMoveContext('myMove', edit=True,
                                   mode=0)  # object mode
             Cache.currentContext = 'myMove'
             self.setAttributes()
     except:
         if Cache.keyOffset == 0:
             cmds.manipMoveContext('myMove', mode=2)  # world mode
             Cache.currentContext = 'myMove'
             self.setAttributes()
         else:
             cmds.manipMoveContext('myMove', mode=0)  # object mode
             Cache.currentContext = 'myMove'
             self.setAttributes()
     cmds.setToolTo(Cache.currentContext)
Ejemplo n.º 38
0
    def ldmt_flatten(self, direction):
        cmds.undoInfo(ock=1)
        cmds.setToolTo('Move')
        cmds.manipMoveContext('Move', e=1, mode=10)
        pivotPositionArray = cmds.manipMoveContext('Move', q=1, p=1)
        pivotPosition = (pivotPositionArray[0], pivotPositionArray[1],
                         pivotPositionArray[2])
        orientAxesArray = cmds.manipMoveContext('Move', q=1, oa=1)
        orientAxes = (math.degrees(orientAxesArray[0]),
                      math.degrees(orientAxesArray[1]),
                      math.degrees(orientAxesArray[2]))
        cmds.manipMoveContext('Move', e=1, mode=2)

        if direction == 'x':
            cmds.scale(1e-05, 1, 1, ws=1, r=1, p=pivotPosition)
        elif direction == 'y':
            cmds.scale(1, 1e-05, 1, ws=1, r=1, p=pivotPosition)
        elif direction == 'z':
            cmds.scale(1, 1, 1e-05, ws=1, r=1, p=pivotPosition)
        elif direction == 'average':
            cmds.scale(1e-05, 1, 1, oa=orientAxes, r=1, p=pivotPosition)
            cmds.manipMoveContext('Move', e=1, mode=10)
        cmds.undoInfo(cck=True)
Ejemplo n.º 39
0
def orientTemplateToComponent():
    # Get selection
    selection = cmds.ls (sl=True)
    length = len(selection)
    
    # If statement to see if enough things were selected
    if length < 2:
        print "Not enough things selected to run script."
        
    else: 
        # First thing selected is controller
        thingA = selection[0] 
        
        # Second thing selected is the object/component you want to snap and orient template to
        thingB = selection[1]
        
        # Get position of thingB
        cmds.select (thingB, r=True)
        cmds.setToolTo('moveSuperContext')
        tempLoc =  cmds.spaceLocator(p=cmds.manipMoveContext('Move', q=True, p=True), a=True)
        cmds.xform(cp=True)
       
        # Get constraint settings from UI
       
        aimValue1 = cmds.floatFieldGrp ("MPCCarUI|MPCCar_mainColumnLayout|MPCCar_mainTabLayout|Step_2|orientAimAttrs", q=True, value1=True)
        aimValue2 = cmds.floatFieldGrp ("MPCCarUI|MPCCar_mainColumnLayout|MPCCar_mainTabLayout|Step_2|orientAimAttrs", q=True, value2=True)
        aimValue3 = cmds.floatFieldGrp ("MPCCarUI|MPCCar_mainColumnLayout|MPCCar_mainTabLayout|Step_2|orientAimAttrs", q=True, value3=True)
        upValue1 = cmds.floatFieldGrp ("MPCCarUI|MPCCar_mainColumnLayout|MPCCar_mainTabLayout|Step_2|orientUpAttrs", q=True, value1=True)
        upValue2 = cmds.floatFieldGrp ("MPCCarUI|MPCCar_mainColumnLayout|MPCCar_mainTabLayout|Step_2|orientUpAttrs", q=True, value1=True)
        upValue3 = cmds.floatFieldGrp ("MPCCarUI|MPCCar_mainColumnLayout|MPCCar_mainTabLayout|Step_2|orientUpAttrs", q=True, value1=True)
       
        # Normal constraint the TEMP loc
        cmds.normalConstraint (thingB, tempLoc[0], w=1, aimVector = (aimValue1, aimValue2, aimValue3), upVector = (upValue1, upValue2, upValue3), worldUpType="vector", worldUpVector = (0, 1, 0))
       
        # Move thingA with parent constraint with maintain offset turned off
        tempParentConstraint = cmds.parentConstraint ( (tempLoc[0]), (thingA), mo=False )
        
        # Delete things
        cmds.delete (tempParentConstraint,  tempLoc[0] )
Ejemplo n.º 40
0
    def translateModePress(self):
        cmds.TranslateToolWithSnapMarkingMenu()

        mode = int(cmds.manipMoveContext('Move', q=True, mode=True))

        if self.tool == 'moveSuperContext':
            if mode == 1:
                # 0 = Object, 1 = Local, 2 = World, 3 = Normal, 4 = Rotation Axis
                cmds.manipMoveContext('Move', e=True, mode=2)
                self.printMode('World', changed=True)
            elif mode == 2:
                cmds.manipMoveContext('Move', e=True, mode=0)
                self.printMode('Object', changed=True)
            elif mode == 0:
                cmds.manipMoveContext('Move', e=True, mode=1)
                self.printMode('Local', changed=True)

        elif mode == 0:
            self.printMode('Object')
        elif mode == 2:
            self.printMode('World')
        elif mode == 1:
            self.printMode('Local')
Ejemplo n.º 41
0
def createSoftCluster(excludeObjs=None, supportTypes=None):
    # determind select objects
    initSel = cmd.ls(sl=1, ap=1, st=1)
    firstSelObj, firstSelType = initSel[0], initSel[1]

    if firstSelType == 'transform':
        object = firstSelObj
    elif firstSelType in ['float3', 'double3']:
        object = cmd.listRelatives(cmd.listRelatives(p=True, f=1), p=True,
                                   f=1)[0]
    else:
        cmd.error('Selected objects Unsupported!')
        return

    # query manipulator's position
    cmd.setToolTo('Move')
    currentMoveMode = cmd.manipMoveContext('Move', q=True, m=True)
    cmd.manipMoveContext('Move', e=True, m=0)
    position = cmd.manipMoveContext('Move', q=True, p=True)
    cmd.manipMoveContext('Move', e=True, m=currentMoveMode)

    # query influenced elements and correspond weights
    elements = cmd.softSelectionQuery(cmp=1, exo=excludeObjs, t=supportTypes)
    weights = cmd.softSelectionQuery(w=1, exo=excludeObjs, t=supportTypes)

    # create cluster with elements and set weights
    try:
        clusterNode, clusterHandle = cmd.cluster(elements,
                                                 n='%s_softCluster' %
                                                 object.split('|')[-1])
    except:
        cmd.error('Selected objects Unsupported!')
        return

    for i in xrange(len(elements)):
        cmd.percent(clusterNode, elements[i], v=weights[i])

    repositionCluster(clusterHandle, position)

    return clusterNode, clusterHandle
Ejemplo n.º 42
0
def create_soft_cluster():
    """
    Create a Cluster deformer using the current soft selection.

    :return: New cluster deformer.
    :rtype: str
    """
    elements, weights = _get_soft_selection()

    # Get the average position from the move manipulator
    mc.setToolTo('Move')
    current_mode = mc.manipMoveContext('Move', q=True, m=True)
    mc.manipMoveContext('Move', e=True, m=0)
    position = mc.manipMoveContext('Move', q=True, p=True)
    mc.manipMoveContext('Move', e=True, m=current_mode)

    obj = mc.listRelatives(mc.listRelatives(parent=True), parent=True)
    new_cluster = mc.cluster(elements, n=obj[0] + '_softCluster')
    for i in range(len(elements)):
        mc.percent(new_cluster[0], elements[i], v=weights[i])

    _reposition_cluster_deformer(new_cluster[1], position)
Ejemplo n.º 43
0
def runMethod( category, curveName, *args ):

	try:
		CurveName = curveName[0].capitalize() + curveName[1:]
		exec( 'from codes.python.%s import %s'%(category,curveName) ) # ie: from ehm_tools.codes.curves import cubeCrv
		exec( 'reload(%s)'%(curveName) ) # ie: reload( cubeCrv )
		exec( '%s.%s()'%( curveName, CurveName)  ) # ie: cubeCrv.CubeCrv()
	except NameError:
		cmds.warning( '"%s" function does not exist!'%method )
	

	
#####################################################################################
# get rid of auto orient joint in move option box
cmds.manipMoveContext( 'Move', e=True, orientJointEnabled=0 )


#####################################################################################
# set time setting to 25 fps
cmds.currentUnit( t="pal" )


#####################################################################################
# Add M:\MAYA_DEV\plugins; to maya's user plugin path


# fine Maya.env file located in user pref directory
path = cmds.internalVar( upd=True )
path = os.path.join( path[:-6].replace('/','\\'), 'Maya.env' )
Ejemplo n.º 44
0
def UI():
    mc.frameLayout('Furioso',w=ui.rowWidth,cll=1,bgc=[.2,.2,.2],fn='smallBoldLabelFont',bs='in',l='Furioso')
    
    mc.columnLayout('furiosoObjectConform',cal='center',w=ui.rowWidth-10)
    mc.rowColumnLayout(numberOfColumns=8)
    mc.iconTextButton(w=ui.iconSize,h=ui.iconSize,ann="Create 10x10 Tile",l= "Tile" ,i= "polyPlane.png",c=partial(delay,'mel.eval','("polyPlane -w 10 -h 10 -sx 10 -sy 10 -ax 0 1 0 -cuv 2 -ch 1")'))	
    mc.iconTextButton(w=ui.iconSize,h=ui.iconSize,ann="Create 1x1 Tile",l= "Tile" ,i= "plane.png",c=partial(delay,'mel.eval','("polyPlane -w 10 -h 10 -sx 1 -sy 1 -ax 0 1 0 -cuv 2 -ch 1;")'))
    mc.iconTextButton(w=ui.iconSize,h=ui.iconSize,i= "cube.png",c=partial(delay,'mel.eval','("polyCube -w 10 -h 10 -d 10 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1;")'))
    mc.iconTextButton(w=ui.iconSize,h=ui.iconSize,i= "historyPulldownIcon.png",bgc=[.5,0,0],c=partial(delay,'mel.eval','("DeleteHistory")'))
    mc.iconTextButton(w=ui.iconSize,h=ui.iconSize,i= "",en=0,c=partial(delay,'mel.eval','("polyPlane -w 10 -h 10 -sx 1 -sy 1 -ax 0 1 0 -cuv 2 -ch 1;")'))  
    mc.iconTextButton(w=ui.iconSize,h=ui.iconSize,ann="Set Camera to Meters",en=1,l= "Set Camera" ,i= "CameraAE.png",c=partial(delay,'mel.eval','("rcSetCameraClip .5 100000")'))
    mc.iconTextButton(w=ui.iconSize,h=ui.iconSize,i= "polyQuad",c=partial(delay,'mel.eval','("TogglePolyCount")'))
    mc.iconTextCheckBox(w=ui.iconSize,h=ui.iconSize,ann="Snap",l= "Tile" ,i= "snapGrid.png",onc=partial(delay,'rc.stepSnap','(5,1)'),ofc=partial(delay,'rc.stepSnap','(5,0)'),v=mc.manipMoveContext('Move',q=1,s=1))    
    mc.setParent('..')

    mc.rowLayout(w=ui.rowWidth,numberOfColumns=3)
    mc.button(w=ui.rowWidth/3,h=ui.btn_large,al='left',l=' + ',c=partial(delay,'btnPlus','(mc.ls(sl=1))'))  #
    mc.button(h=ui.btn_large,w=ui.rowWidth/3,al='center',l=' - ',c=partial(delay,'btnDel','("sel")')) 
    mc.button(h=ui.btn_large,w=ui.rowWidth/3,al='right',l='NUKE',c=partial(delay,'btnDel','("all")'))
    mc.setParent('..')
    
    mc.checkBox('Object',vis=0,l='Object',v=int(furiosoPrefs.get('Object')),cc=partial(delay,'furiosoPrefs.checkBox',"('Object')"))
    mc.checkBox('Material',l='Material',vis=1,v=int(furiosoPrefs.get('Material')),cc=partial(delay,'furiosoPrefs.checkBox',"('Material')"))
    mc.checkBox('Flag',l='Flag',vis=0,v=int(furiosoPrefs.get('Flag')),cc=partial(delay,'furiosoPrefs.checkBox',"('Flag')"))
    mc.iconTextScrollList('FuriosoObjScroll',w=ui.rowWidth,h=500)
    mc.setParent('furiosoObjectConform')
    mc.setParent('..')
    
    buildUILists()
Ejemplo n.º 45
0
import pymel.core as pm
import maya.cmds as mc

mc.setToolTo('moveSuperContext')
edges = pm.ls(sl=True, fl=True)
#edges_sorted = sorted(edges, key=lambda e: e.index())
positions = []
for edge in edges:
    pm.polySelect(edge, el=edge.index()) # ns=True if no selection...figure this out.
    positions.append(mc.manipMoveContext('Move', q=True, p=True))

pm.curve(p=positions, degree=1)
Ejemplo n.º 46
0
 def grabOffsetCtrl(self, motionTrail, *args):
     cmds.select(self.nodeInfo[motionTrail]["offsetNode"])
     cmds.setToolTo("Move")
     cmds.manipMoveContext('Move', edit=True, mode=0)
Ejemplo n.º 47
0
def stepSnap(amt,value):
    mc.manipMoveContext('Move',e=1,snapValue= amt);
    mc.manipMoveContext('Move',e=1,s=value);