Ejemplo n.º 1
0
def xRaySwitcher():
	selected = cmds.ls(sl=True,long=True)

	for eachSel in selected:
		if cmds.displaySurface(eachSel, q=True, xRay=True)[0] == True:
			cmds.displaySurface(eachSel, xRay=False)
		else:
			cmds.displaySurface(eachSel, xRay=True)
Ejemplo n.º 2
0
 def makePairs(self):
     sel = cmds.ls(os=1)
     garments = cmds.listRelatives(sel[0])  # len(garments)
     patterns = cmds.listRelatives(sel[1])  # len(patterns)
     retopos = cmds.listRelatives(sel[2])  # len(retopos)
     retopos_BB_width = {}
     retopos_BB_length = {}
     retopos_BB_center = {}
     patterns_BB_width = {}
     patterns_BB_length = {}
     patterns_BB_center = {}
     # In case that uv doesn't exists.
     cmds.select(retopos, r=1)
     mel.eval("performPolyAutoProj 0;")
     cmds.select(sel, r=1)
     # In case wrong bb
     for i in retopos:
         cmds.polyMergeVertex(i, d=0.001)
     # Matching
     for i in retopos:
         BB = cmds.polyEvaluate(i, b=1)
         retopos_BB_width[i] = BB[0][1] - BB[0][0]
         retopos_BB_length[i] = BB[1][1] - BB[1][0]
         retopos_BB_center[i] = [(BB[0][1] + BB[0][0]) / 2,
                                 (BB[1][1] + BB[1][0]) / 2]
     for i in patterns:
         BB = cmds.polyEvaluate(i, b=1)
         patterns_BB_width[i] = BB[0][1] - BB[0][0]
         patterns_BB_length[i] = BB[1][1] - BB[1][0]
         patterns_BB_center[i] = [(BB[0][1] + BB[0][0]) / 2,
                                  (BB[1][1] + BB[1][0]) / 2]
     pair_pattern_retopo = {}  # len(pair_pattern_retopo)
     for i in patterns:
         for j in retopos:
             if      abs(patterns_BB_width[i] - retopos_BB_width[j])         < 1 \
                 and abs(patterns_BB_length[i] - retopos_BB_length[j])       < 1 \
                 and abs(patterns_BB_center[i][0] - retopos_BB_center[j][0]) < 1 \
                 and abs(patterns_BB_center[i][1] - retopos_BB_center[j][1]) < 1:
                 pair_pattern_retopo[i] = j
     for i in pair_pattern_retopo:
         cmds.transferAttributes(i, pair_pattern_retopo[i], transferUVs=1)
     for i in pair_pattern_retopo:
         cmds.select(pair_pattern_retopo[i], i, r=1)
         cmds.CreateWrap()
     for i in pair_pattern_retopo:
         pairGarment = i[:-8]
         pattern = i
         blendObjs = [pairGarment, pattern]  # 0: target 1: origin
         blendName = cmds.blendShape(blendObjs,
                                     o='world',
                                     n='clothTransfer#')
         cmds.hide(sel[1])
         cmds.displaySurface(sel[0], x=1)
     cmds.hide(sel[1])
     cmds.displaySurface(sel[0], x=1)
     layerName = cmds.createDisplayLayer(n="garment#", e=1)
     cmds.editDisplayLayerMembers(layerName, sel[0])
     cmds.setAttr(layerName + '.displayType', 2)
Ejemplo n.º 3
0
def toggle_x_ray_display(objects):
    """
    Toggles the X-Ray display in the viewport of the given objects.
    :param list objects:
    """
    if objects:
        x_ray_status = not cmds.displaySurface(
            objects[0], query=True, xRay=True)[0]
        for obj in objects:
            cmds.displaySurface(obj, xRay=x_ray_status)
Ejemplo n.º 4
0
def display_xray():
    """
    Toggles xray on selected objects.
    """
    selected = mampy.daglist()
    if not selected:
        return logger.warn("Nothing selected.")

    for dag in selected:
        if dag.shape and dag.shape.type == MFn.kMesh:
            state = cmds.displaySurface(str(dag.shape), q=True, xRay=True).pop()
            cmds.displaySurface(str(dag.shape), xRay=not (state))
Ejemplo n.º 5
0
def objXray():
    getObjShp = mc.ls(sl=True, dag=True, ap=True, s=True)
    labelXrayOn = 'Xray On'
    labelXrayOff = 'Xray Off'

    for xrayObj in getObjShp:
        xrayState = mc.displaySurface(xrayObj, q=True, x=True)
        if xrayState[0] == True:
            mc.displaySurface(xrayObj, x=0)
            mc.button('btn10', e=True, l=labelXrayOff)
        else:
            mc.displaySurface(xrayObj, x=1)
            mc.button('btn10', e=True, l=labelXrayOn)
Ejemplo n.º 6
0
def nwXraySelectedToggle():
    # get selected
    sel = cmds.ls(sl=1)
    xRayDisp = []
    # query xray mode
    if sel:
        for shape in sel:
            cmds.select(shape)
            xRay = cmds.displaySurface(query=True, xRay=True)
            if xRay == [False]:
                cmds.displaySurface(xRay=True)
            else:
                cmds.displaySurface(xRay=False)
    cmds.select(sel)
Ejemplo n.º 7
0
def main(log=None):
    if not log:
        import logging
        log = logging.getLogger()

    allObj = cmds.ls(dag=True, type=['mesh', 'nurbsSurface', 'subdiv'])
    try:
        cmds.displaySurface(allObj, twoSidedLighting=False)
        log.debug("turn off double display success")
    except:
        log.debug("turn off double display failure")
        for x in allObj:
            try:
                cmds.displaySurface(x, twoSidedLighting=False)
            except:
                log.error('can not set two side lighting false for %s' % x)
            else:
                pass
Ejemplo n.º 8
0
def main(log=None):
    if not log:
        import logging
        log = logging.getLogger()
        
    allObj = cmds.ls( dag = True, type = ['mesh', 'nurbsSurface', 'subdiv'])
    try:
        cmds.displaySurface(allObj,twoSidedLighting = False)
        log.debug("turn off double display success")
    except:
        log.debug("turn off double display failure")
        for x in allObj:
            try:
                cmds.displaySurface(x,twoSidedLighting = False)
            except:
                log.error('can not set two side lighting false for %s' % x)
            else:
                pass
Ejemplo n.º 9
0
def xRayToggle():
    '''
    Toggles between XRay mode and shaded on a per object basis.
    '''
    sel = cmds.ls(sl=True, dag=True, ap=True, typ='surfaceShape')
    hilighted = cmds.ls(hl=True, dag=True, ap=True, typ='surfaceShape')

    for obj in hilighted:
        test = cmds.displaySurface(obj, q=True, xRay=True)
        hold = test[0]

        if hold:
            cmds.displaySurface(obj, xRay=False)
        else:
            cmds.displaySurface(obj, xRay=True)

    for obj in sel:
        test = cmds.displaySurface(obj, q=True, xRay=True)
        hold = test[0]

        if hold:
            cmds.displaySurface(obj, xRay=False)
        else:
            cmds.displaySurface(obj, xRay=True)
Ejemplo n.º 10
0
def xRayToggle():
    '''
    Toggles between XRay mode and shaded on a per object basis.
    '''
    sel = cmds.ls(sl=True, dag=True, ap=True, typ='surfaceShape')
    hilighted = cmds.ls(hl=True, dag=True, ap=True, typ='surfaceShape')

    for obj in hilighted:
        test = cmds.displaySurface(obj, q=True, xRay=True)
        hold = test[0]

        if hold:
            cmds.displaySurface(obj, xRay=False)
        else:
            cmds.displaySurface(obj, xRay=True)

    for obj in sel:
        test = cmds.displaySurface(obj, q=True, xRay=True)
        hold = test[0]

        if hold:
            cmds.displaySurface(obj, xRay=False)
        else:
            cmds.displaySurface(obj, xRay=True)
Ejemplo n.º 11
0
def nwXrayAllToggle():
    # list all objects
    allObjects = cmds.ls(shapes=True)
    allMesh = []
    xRayDisp = []
    # get meshes
    for obj in allObjects:
        if cmds.nodeType(obj) == 'mesh':
            allMesh.append(obj)
    # get smoothed
    for shape in allMesh:
        # check for notes
        list = cmds.attributeQuery('notes', node=shape, ex=True)
        # notes dont exist
        if not list:
            cmds.select(shape)
            xRay = cmds.displaySurface(query=True, xRay=True)
            # get mesh with xRay display turned on
            if xRay == [True]:
                xRayDisp.append(shape)
                cmds.addAttr(shape, ln='notes', sn='nts', dt='string')
                cmds.setAttr(shape + '.notes', 'xray', type='string')
                cmds.select(cl=True)
            else:
                cmds.select(cl=True)
        # notes do exist
        else:
            # get notes
            note = cmds.getAttr(shape + '.notes')
            # get xray displayed
            if note == 'xray':
                xRayDisp.append(shape)
    # toggle xray display
    for shapes in xRayDisp:
        cmds.select(shapes)
        xRay = cmds.displaySurface(query=True, xRay=True)
        if xRay == [True]:
            cmds.displaySurface(xRay=False)
        else:
            cmds.displaySurface(xRay=True)
    cmds.select(xRayDisp)
Ejemplo n.º 12
0
 def xray(self):#Selected Objects x-Rayed
 	for each in mc.ls(sl=1,s=1,dag=1): 
 		mc.displaySurface(each,xRay=not mc.displaySurface(each,q=1,xRay=1)[0])
Ejemplo n.º 13
0
'''

	Toggle Xray Mode
'''

import maya.cmds as cmds

selection = cmds.ls(sl=True)
for sel in selection:

    xray = cmds.displaySurface(sel, q=True, xRay=True)
    cmds.displaySurface(sel, xRay=not xray[0])