Пример #1
0
    def useLibraryMesh(self):
        """
    This function allows the user to select a mesh for the library creation
    """
        #When the button is clicked, first we get a duplicate of the mesh
        selectedMesh = cmds.ls(sl=True)
        if not selectedMesh:
            #This means nothing is selected. So don't do anything
            return

        self.workMesh = cmds.duplicate(n='TubxLibraryMesh', rr=True)
        #We we isolate the object
        cmds.select(self.workMesh)
        cmds.isolateSelect('modelPanel4', state=1)
        cmds.select(self.workMesh)
        cmds.isolateSelect('modelPanel4', addSelected=True)

        #We create the shaders
        LibraryGeneration.createShaders()

        #Finally, we assign the default shader to the workMesh
        cmds.sets(self.workMesh, edit=True, forceElement='TubxDefaultSG')

        #We also enable tracking selection so we can get the order of selection for the ear vertex
        self.TrackingStatus = cmds.selectPref(q=True, trackSelectionOrder=True)
        cmds.selectPref(trackSelectionOrder=True)
Пример #2
0
def temp5(x=True, y=True, z=True):
    '''
    吸附顶点
    :return:
    '''
    cmds.selectPref()
    points = cmds.ls(os=True)
    print
    points
    if len(points) != 2:
        cmds.warning(u'只能选取两个点')
        return

    originalPosint = points[0]
    originalPosintVector = cmds.pointPosition(originalPosint)
    originalPosint_x = originalPosintVector[0]
    originalPosint_y = originalPosintVector[1]
    originalPosint_z = originalPosintVector[2]

    aimPoint = points[1]
    aimPointVector = cmds.pointPosition(aimPoint)
    aimPoint_x = aimPointVector[0]
    aimPoint_y = aimPointVector[1]
    aimPoint_z = aimPointVector[2]

    cmds.select(originalPosint)

    if x:
        cmds.move(aimPoint_x, x=True)
    if y:
        cmds.move(aimPoint_y, y=True)
    if z:
        cmds.move(aimPoint_z, z=True)
Пример #3
0
 def cancel(self):
     """
     Cancel button action -> close the rigArgs dialog
     :return: None
     """
     self.close()
     cmds.selectPref(tso=self.TSO_Type)
Пример #4
0
def addButtonCallback(*Args):
    pValue = pm.textFieldButtonGrp("addingNewFields", query=True, text=True)
    cmds.selectPref(trackSelectionOrder=True)
    mySelection = cmds.ls(os=True)

    nameWrite = open(
        'EqualRealityData\SelectionData%s.txt' % (globalGender[0]), 'a')
    vertexWrite = open(
        'EqualRealityData\SelectedVerticies%s.txt' % (globalGender[0]), 'a')

    if (pValue not in globalNameKey):
        if cmds.ls(sl=True) == []:
            print('nothing is selected')
        else:
            nameWrite.write('\r\n%s' % (pValue))
            vertexWrite.write('\r\n\r\n')
            for item in mySelection:
                vertexWrite.write('%s,' % (item))
            vertexWrite.close()
            nameWrite.close()
            pm.select(clear=True)

            rolloutParameters(names=['modellingToolkit', 'bodypartSelection'],
                              edit=True)
            createUI('Poly Morph')
    else:
        fileWrite.close()
        print('Cant add... thats a duplicate!')
Пример #5
0
    def timerEvent(self):
        u'''
        timerEvent 计时器事件

        计时器启动后不断累加
        如果计时器累加了两次则说明是单击
        停止计时器并且触发单击事件
        '''
        self.timer.stop()
        # print "tab_long_press",self.tab_long_press
        # print "timer_count",self.timer_count
        if self.timer_count <= 1:
            # NOTE 如果小于等于 3 说明不是长按
            if self.tab_long_press <= 3:
                self.show()
                # NOTE 选择输入
                self.search.selectAll()
                # NOTE 弹出当前置顶集
                self.search.jumpToPins()

            self.tab_long_press = 0
        else:
            if self.tab_long_press == 0:
                cmds.selectPref(psf=0, ps=0)
            if self.isVisible():
                self.hide()
                self.results.hide()

        self.timer_count = 0
Пример #6
0
def match(*args):
    # get the state of options
    modeOpt = cmds.optionMenu('modeOptMenu', q=True, v=True)
    tOpt = cmds.checkBoxGrp('optChkGrp', q=True, v1=True)
    rOpt = cmds.checkBoxGrp('optChkGrp', q=True, v2=True)
    sOpt = cmds.checkBoxGrp('optChkGrp', q=True, v3=True)
    mOpt = cmds.checkBox('mirChk', q=True, v=True)
    loOpt = cmds.checkBox('loChk', q=True, v=True)
    rvrsOpt = cmds.checkBox('rvrsSel', q=True, v=True)

    selList = cmds.ls(orderedSelection=True)
    # if first selected item is component, trackSlectionOrder
    if '[' in selList[0]: cmds.selectPref(trackSelectionOrder=True)
    src = selList[0]
    trg = selList[1]

    if rvrsOpt:
        src, trg = trg, src

    if modeOpt == 'Xform':
        matchWithXfrom(tOpt, rOpt, sOpt, mOpt, src, trg, loOpt)
    else:
        matchWithConst(tOpt, rOpt, sOpt, src, trg)

    cmds.select(trg, r=True)
Пример #7
0
def morphAttrDo(*args):
    print "in morph attr do"
    if not cmds.selectPref(q=True, trackSelectionOrder=True):
        cmds.selectPref(trackSelectionOrder=True)

    sel = cmds.ls(orderedSelection=True)

    if not sel or len(sel) < 3:
        cmds.warning("You need to select a sequence of objects!")
        return ()

    chnls = getChannels()

    if not chnls:
        cmds.warning("You need to select a channel in the channelbox!")
        return ()

    first = sel[0]
    last = sel[-1]

    for c in chnls:
        firstVal = cmds.getAttr("{0}.{1}".format(first, c))
        lastVal = cmds.getAttr("{0}.{1}".format(last, c))

        diff = lastVal - firstVal
        incr = diff / len(sel[1:])

        x = 1
        for obj in sel[1:-1]:
            cmds.setAttr("{0}.{1}".format(obj, c), (x * incr))
            x += 1
Пример #8
0
    def __init__(self, instance, uiName, functionName):

        logging.basicConfig()
        logger = logging.getLogger('%s' % uiName)
        logger.setLevel(logging.INFO)

        try:
            cmds.deleteUI('%s' % uiName)
        except:
            logger.info('No %s exists!' % uiName)

        super(EditWidget, self).__init__(parent=instance)
        self.setObjectName('%s' % uiName)
        self.setWindowTitle('%s' % uiName)
        self.setModal(False)

        self.instance = instance
        self.functionName = functionName

        # Turn on track selection order for selecting vertices and lines 1 by 1
        self.TSO_Type = cmds.selectPref(q=1, tso=1)
        cmds.selectPref(tso=1)

        self.buildUI()
        self.populate()
        self.show()
        self.refreshListWidget()
Пример #9
0
def bufMoveRelease():
    """release the Buf move vertex mode"""
    activePanel = cmds.getPanel(withFocus=True)
    cmds.modelEditor(activePanel, e=True, manipulators=True)
    cmds.setToolTo('moveSuperContext')
    cmds.selectPref(clickDrag=False)
    cmds.selectMode(component=True)
    cmds.selectMode(object=True)
def create_orient_group():
    #turn on track selection order
    if ( not mc.selectPref(trackSelectionOrder=1, q=1)):
        mc.selectPref(trackSelectionOrder=True)
    sel =  mc.ls(orderedSelection=True)

    if(sel):
        ctrl = sel.pop()
        verts = sel
        print("verts: ", verts)
        if(len(verts)==3 or len(verts)==6):
            #create helper plane/s. Find normals 
            helper_plane_01 = mc.polyCreateFacet( p=[mc.pointPosition(verts[0]), mc.pointPosition(verts[1]), mc.pointPosition(verts[2])] )
            plane01_str_normal = mc.polyInfo(fn=1)[0].split()
            mc.delete(helper_plane_01)
            plane01_normal = (float(plane01_str_normal[2]), float(plane01_str_normal[3]), float(plane01_str_normal[4]))
            vectorN = om.MVector(plane01_normal[0], plane01_normal[1], plane01_normal[2])

            if (len(verts)==6):
                helper_plane_02 = mc.polyCreateFacet( p=[mc.pointPosition(verts[3]), mc.pointPosition(verts[4]), mc.pointPosition(verts[5])] )
                plane02_str_normal = mc.polyInfo(fn=1)[0].split()
                mc.delete(helper_plane_02)
                plane02_normal = (float(plane02_str_normal[2]), float(plane02_str_normal[3]), float(plane02_str_normal[4]))
                vectorT = om.MVector(plane02_normal[0], plane02_normal[1], plane02_normal[2])
            else:
                # if only one plane is provided, find which one of the world axes is orthogonal to the normal
                if (vectorN*om.MVector(1,0,0) == 0):
                    vectorT = om.MVector(1,0,0)
                elif (vectorN*om.MVector(0,1,0) == 0):
                    vectorT = om.MVector(0,1,0)
                elif (vectorN*om.MVector(0,0,1) == 0):
                    vectorT = om.MVector(0,0,1)
                else:
                    #if none of the axes are aligned with a world axis, ask for more verts to define a 2nd plane
                    warning_msg("No axes are aligned with a world axis. You'll need to select 6 vertices and then ctrl.")
                    return

            #find 3rd vector
            vectorX = vectorN^vectorT

            #create orient grp with same pivot as ctrl then parent ctrl
            orientGrp = mc.group(n=str(ctrl).replace('_Ctrl', '_')+'orientGrp', em=1)
            constraint = mc.parentConstraint( ctrl, orientGrp)
            mc.delete(constraint)
            mc.parent(ctrl, orientGrp)

            #make rotation matrix from vectors
            #keep position and assign rotation matrix to orientGrp 
            orientGrp_matrix = mc.xform(orientGrp,q=1, m=1)
            mc.xform(orientGrp, m=(vectorX.x, vectorX.y, vectorX.z, 0, vectorN.x, vectorN.y, vectorN.z, 0, vectorT.x, vectorT.y, vectorT.z, 0,orientGrp_matrix[12],orientGrp_matrix[13],orientGrp_matrix[14],orientGrp_matrix[15] ))
            #freeze transforms
            mc.makeIdentity(orientGrp, apply=1, t=1, n=0)
        else:
            warning_msg("Please select 3 or 6 vertices and then ctrl")
            return
    else:
        warning_msg("Please select 3 or 6 vertices and then ctrl")
        return
def openSkinclusterClipboard(*args):
    for i in shiboken2.wrapInstance(long(omui.MQtUtil.mainWindow()), QMainWindow).findChildren(SkinclusterClipboard):
        i.close()

    if not mc.selectPref(q=True, tso=True):
        mc.selectPref(tso=True)

    SCB = SkinclusterClipboard()
    SCB.show()
Пример #12
0
    def setData(self):
        """
        Save the rigArgs info and close the rigArgs dialog
        :return: None
        """
        self.saveData()

        self.close()

        cmds.selectPref(tso=self.TSO_Type)
Пример #13
0
def cam_base_sel():
    # Query the Move tool Selection style: Camera-base selection
    on = cmds.selectPref(q=True, useDepth=True)

    # If the Camera-base selection is off, turn it on
    if not on:
        cmds.selectPref(useDepth=True)

    # If the Camera-base selection is on, turn it off
    else:
        cmds.selectPref(useDepth=False)
Пример #14
0
 def setupUi(self, edo_ThreePointMatherUI):
     ETPMUI.Ui_edo_ThreePointMatherUI.setupUi(self,edo_ThreePointMatherUI)
     self.loadSource_bt.clicked.connect(self.edo_getSelectedSourcePoint_)
     self.loadTarget_bt.clicked.connect(self.edo_getSelectedTargetPoint_)
     self.transformMatch_bt.clicked.connect(self.edo_transformMatchCmd_)
     self.transformMatchMO_bt.clicked.connect(self.edo_transformMatchMOCmd_)
     self.controlerMatch_bt.clicked.connect(self.edo_ctrlMatchCmd_)
     print 'set trackSelection on...'
     t=cmds.selectPref( q=1,trackSelectionOrder=1 )
     if t==False:
         cmds.selectPref( trackSelectionOrder=1 )
Пример #15
0
    def execOption_(self):
        if not self.commandOption:
            return

        window = self.window()
        window.hide()
        window.parent.hide()
        cmds.selectPref(ps=0, psf=0)
        if hasattr(self.commandOption, "trigger"):
            self.commandOption.trigger()
        else:
            self.commandOption()
Пример #16
0
def createJntByVTX_showUI():
	uipath='U:/RiggerAdderMenu/createJntByVTX/createJntByVtx.ui'
	if(cmds.window('weana_createJntByVtx_window',q=1,ex=1)):cmds.deleteUI('weana_createJntByVtx_window')
	ui = cmds.loadUI(f=uipath)
	cmds.showWindow(ui)
	#
	cmds.selectPref(trackSelectionOrder=True)
	#
	#cmds.button('refresh_button',e=True,command='selectRefresh()')
	cmds.button('createJntByVtx_button',e=True,command='createJntByVtx()')
	cmds.button('index_button',e=True,command='setIndex_field()')
	cmds.button('multCreate_button',e=True,command='multCtrateJnt()')
	cmds.textField('baseName_textField',e=True,text='base')
Пример #17
0
 def initSelectStyle(self):
     if mc.selectPref(q=True, paintSelect=True):
         mc.iconTextRadioButton(self.bt_dragSelStyle, edit=True, select=True)
         if mc.selectPref(q=True, paintSelectWithDepth=True):
             mc.iconTextCheckBox(self.bt_camSwitch, edit=True, value=True)
         else:
             mc.iconTextCheckBox(self.bt_camSwitch, edit=True, value=False)
     else:
         mc.iconTextRadioButton(self.bt_marqueeSelStyle, edit=True, select=True)
         if mc.selectPref(q=True, useDepth=True):
             mc.iconTextCheckBox(self.bt_camSwitch, edit=True, value=True)
         else:
             mc.iconTextCheckBox(self.bt_camSwitch, edit=True, value=False)
Пример #18
0
def accumulateAttrsChange(val, *args):
    if not cmds.selectPref(q=True, trackSelectionOrder=True):
        cmds.selectPref(trackSelectionOrder=True)

    sel = cmds.ls(orderedSelection=True)

    chnls = getChannels()

    for i in range(0, len(sel)):
        j = val * (i + 1)
        for chnl in chnls:
            currentVal = cmds.getAttr("{0}.{1}".format(sel[i], chnl))
            newVal = j + currentVal
            cmds.setAttr("{0}.{1}".format(sel[i], chnl), newVal)
Пример #19
0
def matrix_from_3_points_selection():
    """
    Get the transformation matrix in world space based on a 2 or 3 point
    selection. The first two points will determine the z-direction and the
    center of those two points will be the position. The 3rd point selection
    is optional, it determines the x-direction which results in a better
    y-direction as well.

    :return: Matrix
    :rtype: list
    """
    # validate selection order
    if not cmds.selectPref(query=True, trackSelectionOrder=True):
        raise RuntimeError(
            "Make sure tracking of the selection order is enabled in the preferences!"
        )

    # get selection
    sel = cmds.ls(os=True, fl=True)

    # validate selection
    if len(sel) < 2:
        raise RuntimeError("Select at least 2 components!")

    return matrix_from_3_points(*sel[:3])
def select_inside_loop():
    
    ####
    # Turn on ordering selection
    if not cmds.selectPref(q=True,trackSelectionOrder=True):
        cmds.selectPref(trackSelectionOrder=True)
    #####

    # get selected face loop and one inner face, convert to edges
    get_sel = cmds.ls(os=1, fl=1)
    if _cmds.is_component(get_sel) == "face":
        mesh = cmds.ls(sl=1, fl=1, o=1)
        edge_from_face = cmds.ls(cmds.polyListComponentConversion(get_sel[:-1], te=1, bo=1), fl=1)

        ######
        cmds.select(d=True)
        ######

        # create temp uvset for uv projection
        current_uvset = cmds.polyUVSet(mesh, q=1, cuv=1)[0]
        
        #######
        if "af_tmp_select_uvset" not in cmds.polyUVSet(mesh, q=1, auv=1):
            cmds.polyUVSet(mesh, create=1, uvSet="af_tmp_select_uvset")
            cmds.polyUVSet(mesh, e=1, cuv=1, uvSet="af_tmp_select_uvset")
        else:
            cmds.polyUVSet(mesh, delete=1, uvSet="af_tmp_select_uvset")
            cmds.polyUVSet(mesh, create=1, uvSet="af_tmp_select_uvset")
            cmds.polyUVSet(mesh, e=1, cuv=1, uvSet="af_tmp_select_uvset")
        ######       

        cmds.polyProjection(mesh, ch=0, type="Planar", ibd=1, md="y")
        cmds.polyMapCut(edge_from_face, e=0)

        # get inner selection
        cmds.select(cmds.polyListComponentConversion(get_sel[-1], tuv=1), r=1)
        mm.eval("polySelectBorderShell 0;ConvertSelectionToFaces;")
        inner = cmds.ls(sl=1, fl=1)

        # cleanup
        cmds.polyUVSet(mesh, e=1, cuv=1, uvSet=current_uvset)
        cmds.polyUVSet(mesh, delete=1, uvSet="af_tmp_select_uvset")
        cmds.delete(mesh, ch=1)
        
        # select fill
        cmds.select((inner + get_sel[:-1]), r=1)
Пример #21
0
 def selectionStyleSwitch(self, *args):
     if mc.selectPref(query=True, paintSelect=True):
         mc.selectPref(paintSelect=False)
         mc.iconTextRadioButton(self.bt_marqueeSelStyle, edit=True, select=True)
         #self.bt_selectionStyle.setText("Marquee")
         print ">> Selection mode is MARQUEE."
         if mc.selectPref(query=True, useDepth=True):
             mc.iconTextCheckBox(self.bt_camSwitch, edit=True, value=True)
             #self.bt_camSwitch.setChecked(True)
             #self.buttonOn(self.bt_camSwitch)
         else:
             mc.iconTextCheckBox(self.bt_camSwitch, edit=True, value=False)
             #self.bt_camSwitch.setChecked(False)
             #self.buttonOff(self.bt_camSwitch)
     else:
         mc.selectPref(paintSelect=True)
         mc.iconTextRadioButton(self.bt_dragSelStyle, edit=True, select=True)
         #self.bt_selectionStyle.setText("Drag")
         print ">> Selection mode is DRAG."
         if mc.selectPref(query=True, paintSelectWithDepth=True):
             mc.iconTextCheckBox(self.bt_camSwitch, edit=True, value=True)
             #self.bt_camSwitch.setChecked(True)
             #self.buttonOn(self.bt_camSwitch)
         else:
             mc.iconTextCheckBox(self.bt_camSwitch, edit=True, value=False)
Пример #22
0
def bufMoveMulti():
    """enter the Buf move vertex mode"""
    try:
        cmds.selectMode(object=True)
        selection = cmds.ls(sl=True)
        cmds.selectMode(component=True)
        cmds.selectMode(object=True)
        cmds.selectMode(component=True)
        for node in selection:
            cmds.delete(node, ch=True)
            mel.eval('doMenuComponentSelection("'+node+'", "meshComponents");')

        activePanel = cmds.getPanel(withFocus=True)
        cmds.modelEditor(activePanel, e=True, manipulators=False)
        cmds.setToolTo('moveSuperContext')
        cmds.selectPref(clickDrag=True)
    except:
        pass
Пример #23
0
    def from_ls(cls, *args, **kwargs):
        merge = True
        if any(i in kwargs for i in ('fl', 'flatten', 'os', 'orderedSelection')):
            if not cmds.selectPref(q=True, trackSelectionOrder=True):
                raise OrderedSelectionsNotSet()
            merge = False

        if 'merge' in kwargs:
            merge = kwargs['merge']
        return cls(cmds.ls(*args, **kwargs), merge)
Пример #24
0
    def from_ls(cls, *args, **kwargs):
        merge = True
        if any(i in kwargs
               for i in ('fl', 'flatten', 'os', 'orderedSelection')):
            if not cmds.selectPref(q=True, trackSelectionOrder=True):
                raise OrderedSelectionsNotSet()
            merge = False

        if 'merge' in kwargs:
            merge = kwargs['merge']
        return cls(cmds.ls(*args, **kwargs), merge)
Пример #25
0
def advanceMoveMulti():
    """
    same as advanceMove but with multicomponents enable
    """
    cmds.selectMode(object=True)
    selection = cmds.ls(sl=True)
    cmds.selectMode(component=True)
    cmds.selectMode(object=True)
    cmds.selectMode(component=True)
    for node in selection:
        cmds.delete(node, ch=True)
        cmds.selectType(meshComponents=True)
        cmds.hilite(node)
        cmds.select(clear=True)
        #mel.eval('dR_selTypeChanged("meshComponents");')

    activePanel = cmds.getPanel(withFocus=True)
    cmds.modelEditor(activePanel, e=True, manipulators=False)
    cmds.setToolTo('moveSuperContext')
    cmds.selectPref(clickDrag=True)
Пример #26
0
def main():
    # turn on selection order
    if (mc.selectPref(tso=1,q=1))==0:
        mc.selectPref(tso=1)
	# select vertices. first one and last one will define the line
    sel = mc.ls(fl=1,os=1)
    if len(sel) > 2:
    	B = mc.pointPosition(sel[0])
    	A = mc.pointPosition(sel[-1])
    	otherPoint = list(sel)
    	otherPoint.remove(sel[0])
    	otherPoint.remove(sel[-1])
    	#for i in range(1,(len(sel)-1)):
    	for point in otherPoint:
    		C = mc.pointPosition(point)
    		Mab = mh.sqrt(mh.pow(B[0]-A[0],2) + mh.pow(B[1]-A[1],2) + mh.pow(B[2]-A[2],2))
    		Mac = mh.sqrt(mh.pow(C[0]-A[0],2) + mh.pow(C[1]-A[1],2) + mh.pow(C[2]-A[2],2))
    		Vab = [(B[0]-A[0])/Mab,(B[1]-A[1])/Mab,(B[2]-A[2])/Mab]
    		Vac = [(C[0]-A[0])/Mac,(C[1]-A[1])/Mac,(C[2]-A[2])/Mac]
    		cosA = Vab[0]*Vac[0]+Vab[1]*Vac[1]+Vab[2]*Vac[2]
    		e = Mac*cosA
    		E = [A[0]+Vab[0]*e,A[1]+Vab[1]*e,A[2]+Vab[2]*e]
    		mc.move(E[0],E[1],E[2],point,ws=1,wd=1)
Пример #27
0
def advanceMove():
    """
    enter a custom click and drag selection mode
    this is to be used with 'advanceMoveRelease'
    """
    cmds.selectMode(component=True)
    cmds.selectMode(object=True)
    sel = cmds.ls(sl=True)
    # enter the move mode and set on vertex
    if sel:
        shape = cmds.listRelatives(sel[0])
        if cmds.nodeType(shape) == 'nurbsCurve':
            try:
                cmds.delete(sel, ch=True)
                cmds.selectMode(component=True)
                activePanel = cmds.getPanel(withFocus=True)
                cmds.modelEditor(activePanel, e=True, manipulators=False)
                cmds.setToolTo('moveSuperContext')
                cmds.selectType(alc=0)
                cmds.selectType(controlVertex=1)
                cmds.selectPref(clickDrag=True)
            except:
                pass

        if cmds.nodeType(shape) == 'mesh':
            try:
                cmds.delete(sel, ch=True)
                cmds.selectMode(component=True)
                activePanel = cmds.getPanel(withFocus=True)
                cmds.modelEditor(activePanel, e=True, manipulators=False)
                cmds.setToolTo('moveSuperContext')
                cmds.selectType(alc=0)
                cmds.selectType(vertex=1)
                cmds.selectPref(clickDrag=True)
            except:
                pass
        else:
            try:
                cmds.delete(sel, ch=True)
                cmds.selectMode(component=True)
                activePanel = cmds.getPanel(withFocus=True)
                cmds.modelEditor(activePanel, e=True, manipulators=False)
                cmds.setToolTo('moveSuperContext')
                cmds.selectType(alc=0)
                cmds.selectType(vertex=1)
                cmds.selectPref(clickDrag=True)
            except:
                pass
Пример #28
0
def bufMove():
    """enter the Buf move vertex mode"""
    cmds.selectMode(component=True)
    cmds.selectMode(object=True)
    sel = cmds.ls(sl=True)
    # enter the move mode and set on vertex
    sel = cmds.ls(sl=True)
    shape = cmds.listRelatives(sel[0])
    print cmds.nodeType(shape)
    if cmds.nodeType(shape) == 'nurbsCurve':
        try:
            cmds.delete(sel, ch=True)
            cmds.selectMode(component=True)
            activePanel = cmds.getPanel(withFocus=True)
            cmds.modelEditor(activePanel, e=True, manipulators=False)
            cmds.setToolTo('moveSuperContext')
            cmds.selectType(alc=0)
            cmds.selectType(controlVertex=1)
            cmds.selectPref(clickDrag=True)
        except:
            pass

    if cmds.nodeType(shape) == 'mesh':
        try:
            cmds.delete(sel, ch=True)
            cmds.selectMode(component=True)
            activePanel = cmds.getPanel(withFocus=True)
            cmds.modelEditor(activePanel, e=True, manipulators=False)
            cmds.setToolTo('moveSuperContext')
            cmds.selectType(alc=0)
            cmds.selectType(vertex=1)
            cmds.selectPref(clickDrag=True)
        except:
            pass
    else:
        try:
            cmds.delete(sel, ch=True)
            cmds.selectMode(component=True)
            activePanel = cmds.getPanel(withFocus=True)
            cmds.modelEditor(activePanel, e=True, manipulators=False)
            cmds.setToolTo('moveSuperContext')
            cmds.selectType(alc=0)
            cmds.selectType(vertex=1)
            cmds.selectPref(clickDrag=True)
        except:
            pass
Пример #29
0
    def eventFilter(self, receiver, event):
        # NOTE 键盘事件
        if hasattr(event, "type") and event.type() == utils.QEvent.KeyRelease:
            # NOTE 敲击 Tab 键
            if event.key() == utils.Qt.Key_Tab and not self.isVisible(
            ) and self.manager.setting.setting_data["Tab_CB"]:
                self.tab_long_press += 1
                if not event.isAutoRepeat():
                    # NOTE 禁用 Tab 拖拽选择
                    cmds.selectPref(psf=1, ps=1)
                    # mel.eval("dR_paintPress;")
                    self.tab_long_press = 0

                if self.timer.isActive():
                    self.timer_count += 1
                else:
                    self.timer.start()

            # NOTE 敲击 Esc 键
            elif event.key() == utils.Qt.Key_Escape:
                self.hide()
                self.results.hide()
                # mel.eval("dR_paintRelease;")
                # cmds.setToolTo(self.curr_ctx)
                cmds.selectPref(psf=0, ps=0)
                self.tab_long_press = 0
            else:
                self.tab_long_press = 0

        # Note 鼠标事件 QEvent.Type.MouseButtonPress 为 2
        elif hasattr(event, "type") and event.type() == 2 and self.isVisible():
            # Note 过滤接受的组件是否是自己 避免其他组件触发 如 PySide2 QWindow 也会传入进来
            if ('QWindow' not in str(receiver)
                    and receiver not in self.children()
                    and receiver not in self.container.children()
                    and receiver not in self.manager.children()
                    and receiver.window() != self.results and receiver != self
                    and type(receiver.parent()) != utils.Divider):
                self.hide()
                # mel.eval("dR_paintRelease;")
                # cmds.setToolTo(self.curr_ctx)
                cmds.selectPref(psf=0, ps=0)

            self.tab_long_press = 0

        return False
Пример #30
0
def run_sel(falloff=1, color=22, sphVis=1, smooth=3, lra=1, mode=1, scale=1):

    tsl = cmds.selectPref(q=1, tso=1)
    if tsl != 1:
        cmds.selectPref(tso=1)

    sel = cmds.ls(sl=1, o=1)
    if sel:
        surf = sel[0]
        comps = cmds.ls(os=1, fl=1)
        bads = []
        for c in comps:
            if '.vtx' not in c and '.cv' not in c and '.u' not in c:
                bads.append(c)
        if not bads:
            comp = comps[-1]
            if '.vtx' in comp:
                sm = run_vtx(comp,
                             surf,
                             falloff=falloff,
                             color=color,
                             sphVis=sphVis,
                             lra=lra,
                             mode=mode,
                             scale=scale)
                if len(comps) >= 2:
                    cmds.setAttr('{}.falloffRadius'.format(sm[1]), 100)
                    cmds.setAttr('{}.sphere'.format(sm[1]), 0)
                    floodReplace(comps, sm[0])
                    if smooth >= 1:
                        floodSmooth(comps, sm[0], smooth=smooth)
                    sys.stdout.write(
                        'Sticky Mod created in multi-vertex mode. Map has been flooded, Falloff Radius set to 100, and sphere visibility disabled.'
                    )
                else:
                    sys.stdout.write('Sticky Mod created!')
                cmds.select(sm[1])
            elif '.u' in comp:
                if len(comps) == 1:
                    sm = run_cp(comp,
                                surf,
                                falloff=falloff,
                                color=color,
                                sphVis=sphVis,
                                lra=lra,
                                mode=mode,
                                scale=scale)
                    sys.stdout.write('Sticky Mod created!')
                else:
                    cmds.warning(
                        'Select at least 1 vertex on 1 mesh, or 1 curve point on 1 curve.'
                    )
            elif '.cv' in comp:
                cmds.warning(
                    'Select at least 1 vertex on 1 mesh, or 1 curve point on 1 curve.'
                )
            else:
                cmds.warning(
                    'Select at least 1 vertex on 1 mesh, or 1 curve point on 1 curve.'
                )
        else:
            cmds.warning(
                'Select at least 1 vertex on 1 mesh, or 1 curve point on 1 curve.'
            )
    else:
        cmds.warning(
            'Select at least 1 vertex on 1 mesh, or 1 curve point on 1 curve.')
Пример #31
0
def defaultSettings():
    # view cube on
    cmds.viewManip(visible=True)
    cmds.optionVar(iv = ["viewCubeShowCube", 1])
    # click box size
    cmds.selectPref(clickBoxSize=4)
Пример #32
0
def customSettings():
    # view cube off
    cmds.viewManip(visible=False)
    cmds.optionVar(iv = ["viewCubeShowCube", 0])
    # click box size
    cmds.selectPref(clickBoxSize=6)
Пример #33
0
def on_key_pressed_begin():
    # mel.eval("selectPref -xformNoSelect false;")
    cmds.selectPref(xformNoSelect=False)
Пример #34
0
def Mari2MayaEx():

    a = ls(selected())

    for i in a:
        print i

    c = PyNode.connections(a[0], connections=True)

    e = '1'

    f = 5

    for i in range(f):
        d = c[5][1][-f]
        if d.isdigit():
            e = c[5][1][-f:]
            break
        f = f - 1

    x = int(e)

    b = []

    for i in range(len(a)):
        b.append('place2dTexture%d' % x)
        x = x + 1

    for i in b:
        print i

    # Setting Wrap U and Wrap V to Off

    for i in b:
        setAttr(str(i + '.wrapU'), 0)
        setAttr(str(i + '.wrapV'), 0)

    # Setting Translate Values for Texture Patches

    for i in range(len(a)):
        if float(a[i][-3]) == 0:
            setAttr(str(b[i] + '.translateFrame'), 9, float(a[i][-4]) - 1)
        else:
            setAttr(str(b[i] + '.translateFrame'),
                    float(a[i][-3]) - 1, float(a[i][-4]))

    # Setting the Default Color to Black

    cmds.selectPref(tso=0) if cmds.selectPref(q=1, tso=1) else cmds.selectPref(
        tso=1)

    print cmds.ls(os=1, fl=1)

    texcol = cmds.ls(os=1, fl=1)

    for i in range(len(texcol)):
        try:
            connectAttr(str(texcol[i] + '.outColor'),
                        str(texcol[i + 1] + '.defaultColor'))
        except IndexError:
            mel.hyperShadePanelGraphCommand("hyperShadePanel1",
                                            "showUpAndDownstream")
        else:
            mel.hyperShadePanelGraphCommand("hyperShadePanel1",
                                            "showUpAndDownstream")
Пример #35
0
def on_key_released():
    # mel.eval("selectPref -xformNoSelect true;")
    cmds.selectPref(xformNoSelect=True)
Пример #36
0
 def camSwitch(self, *args):
     if mc.selectPref(q=True, paintSelect=True):
         if mc.selectPref(q=True, paintSelectWithDepth=True):
             mc.selectPref(paintSelectWithDepth=False)
             mc.iconTextCheckBox(self.bt_camSwitch, edit=True, value=False)
         else:
             mc.selectPref(paintSelectWithDepth=True)
             mc.iconTextCheckBox(self.bt_camSwitch, edit=True, value=True)
     else:
         if mc.selectPref(q=True, useDepth=True):
             mc.selectPref(useDepth=0)
             mc.iconTextCheckBox(self.bt_camSwitch, edit=True, value=False)
         else:
             mc.selectPref(useDepth=1)
             mc.iconTextCheckBox(self.bt_camSwitch, edit=True, value=True)
Пример #37
0
def enable_track_selections():
    # Enable trackSelectionOrder to get proper selection order for aim_selection()
    if not cmds.selectPref(trackSelectionOrder=True):
        cmds.selectPref(trackSelectionOrder=True)
        LOG.info('Track selection order enabled')
Пример #38
0
def gridFill():
    ####        Setting ordered selection as true in the preferences        ####

    cmds.selectPref(trackSelectionOrder=True)
    userOffset = cmds.intField(offsetBox, q=1, v=1)
    userDivision = cmds.intField(divisions, q=1, v=1)
    relax = cmds.optionMenu(relaxChoice, q=1, v=1)

    ####        Getting the original selection          ####
    originalSelection = (cmds.ls(selection=True, flatten=True))
    # Storing the number of vertices in order to be able to relax the new created ones
    cmds.select(clear=True)
    mel.eval("invertSelection;")
    cmds.polyListComponentConversion(fromEdge=True, toVertex=True)
    verticesForExclusion = cmds.polyListComponentConversion(fromEdge=True,
                                                            toVertex=True)
    cmds.select(verticesForExclusion)

    cmds.select(originalSelection)

    #####       Selection changes       ####

    i = 0
    selectionGrowList = []

    mel.eval("invertSelection;")
    invertedOriginal = (cmds.ls(selection=True, flatten=True))

    cmds.select(clear=True)

    # Get the first edge of the border selected
    cmds.select(originalSelection[userOffset + 1])
    if len(originalSelection) % 4 == 0:
        mel.eval('select `ls -sl`;PolySelectTraverse 1;select `ls -sl`;')
        cmds.select(invertedOriginal, deselect=True)
        originalOddSelection = (cmds.ls(selection=True, flatten=True))
        cmds.select(clear=True)
        cmds.select(originalOddSelection[0], originalOddSelection[1])

    # Grow selection until the whole border is selected
    while i < (len(originalSelection) / 2 - 1):
        mel.eval('select `ls -sl`;PolySelectTraverse 1;select `ls -sl`;')
        selectionGrowList.append(cmds.ls(selection=True, flatten=True))
        i += 1

    # Finding the two middle edges of the list
    midHalf = (i / 2)
    midSubstract = (i / 2) - 2

    # Reset i value
    i = 0

    ####        Selecting the two opposite edges suites         ####

    # Selecting the first two opposite edges
    cmds.select(clear=True)
    cmds.select(selectionGrowList[midHalf])
    cmds.select(selectionGrowList[midSubstract], deselect=True)
    cmds.select(invertedOriginal, deselect=True)

    # Growing the selection by the number of user divisions
    while i < userDivision - 4:
        mel.eval('select `ls -sl`;PolySelectTraverse 1;select `ls -sl`;')
        i += 1
    cmds.select(invertedOriginal, deselect=True)
    # reset i
    i = 0

    ####        Getting the number of division on the bridge           ####
    firstBridge = cmds.ls(selection=True, flatten=True)

    # The number of divisions needed is equal to the remaining edges on the original edge loop divided by 2 and minus 3
    divisionsNeeded = (len(originalSelection) - len(firstBridge) - 4) / 2 - 1

    # Bridging the first loop and dividing it
    cmds.polyBridgeEdge(divisions=divisionsNeeded)

    # now need to find a way to select the remaining edge loops in order to bridge them
    # The shrink selection around loop should work
    # Should find indications in the cmds.polySelectConstraint( pp=1 ) documentation

    # Get the first edge of the last two bridges
    cmds.select(clear=True)
    cmds.select(originalSelection)
    cmds.select(firstBridge, deselect=True)

    otherBridge = cmds.ls(selection=True, flatten=True)

    # Minus border edges
    mel.eval('select `ls -sl`;PolySelectTraverse 6; select `ls -sl`;')
    actualBridge = cmds.ls(selection=True, flatten=True)

    #Getting border edges to remove for the last two bridges
    cmds.select(clear=True)
    cmds.select(otherBridge)
    cmds.select(actualBridge, deselect=True)
    minusBridge = cmds.ls(selection=True, flatten=True)

    #####        Selecting the remaining bridges           ####

    cmds.select(clear=True)
    cmds.select(otherBridge[0])
    # Selecting the whole loop
    cmds.polySelectSp(loop=True)
    secondBridge = cmds.ls(selection=True, flatten=True)

    # Deselect the minusBridge
    cmds.select(minusBridge, deselect=True)

    cmds.polyBridgeEdge(divisions=0)

    #LastBridge
    cmds.select(clear=True)
    cmds.select(otherBridge)
    #Selecting a single edge from this selection, otherwise the polySelectSp(loop=True) does not work
    cmds.select(secondBridge, deselect=True)
    lastBridge = cmds.ls(selection=True, flatten=True)

    cmds.select(clear=True)
    cmds.select(lastBridge[0])

    # Selecting the whole loop
    cmds.polySelectSp(loop=True)

    # Deselect the minusBridge
    cmds.select(minusBridge, deselect=True)

    cmds.polyBridgeEdge(divisions=0)

    ####        Relax the new vertices      ####
    cmds.select(clear=True)

    if relax == "Yes":
        mel.eval("setSelectMode components Components;")
        mel.eval(
            "selectType -smp 0 -sme 0 -smf 0 -smu 0 -pv 1 -pe 0 -pf 0 -puv 0;")
        cmds.select(verticesForExclusion)
        mel.eval("invertSelection;")
        verticesForRelax = []
        verticesForRelax = cmds.ls(selection=True, flatten=True)
        cmds.polyAverageVertex(verticesForRelax, iterations=100)
        mel.eval(
            "selectType -smp 0 -sme 0 -smf 0 -smu 0 -pv 0 -pe 1 -pf 0 -puv 0;")
        cmds.select(clear=True)
Пример #39
0
    def ldmt_function(self, message):
        cmds.undoInfo(ock=1)
        # Basic Panels
        if message == "UV":
            ldmt_toggleUI.toggleUI('UV')
        elif message == "Shader":
            ldmt_toggleUI.toggleUI('hypershade')
        elif message == "Outliner":
            ldmt_toggleUI.toggleUI('outliner')
        # Transform Tools
        elif message == "Mirror Tool":
            from ldmt_function import ldmt_mirrorTool
            reload(ldmt_mirrorTool)
            ldmt_mirrorTool.ldmt_show()
        elif message == "Reset Pivot":
            from ldmt_function import ldmt_resetPivot
            ldmt_resetPivot.resetPivot()
        elif message == "Flatten Tool":
            from ldmt_function import ldmt_flattenTool
            reload(ldmt_flattenTool)
            ldmt_flattenTool.ldmt_show()
        elif message == "Delete History":
            from ldmt_function import ldmt_deleteHistory
            reload(ldmt_deleteHistory)
            ldmt_deleteHistory.deleteHistory()
        elif message == "Morph To UV":
            from ldmt_function import ldmt_morphToUV
            ldmt_morphToUV.runMorph2UV()
        elif message == "Turbo Smooth":
            from ldmt_function import ldmt_turboSmooth
            ldmt_turboSmooth.ldmt_turboSmooth()
        elif message == "Circularize":
            if ld.MAYA_version_float <= 2017:
                if mel.eval('exists "CircularizeVtxCmd"'):
                    mel.eval("CircularizeVtxCmd")
                else:
                    pluginFile = ldmt_function_path + '/CircularizeVtxCmd.py'
                    cmds.loadPlugin(pluginFile)
                    mel.eval("CircularizeVtxCmd")
            else:
                cmds.polyCircularize()
        elif message == "Rebuild Subdiv":
            from ldmt_function import ldmt_rebuildSubdiv
            ldmt_rebuildSubdiv.ldmt_rebuildSubdiv()
        elif message == "Nanomesh":
            from ldmt_function import ldmt_nanomesh
            reload(ldmt_nanomesh)
            ldmt_nanomesh.ldmt_show()
        elif message == "Insert Mesh":
            mods = cmds.getModifiers()
            pluginPath = ldmt_function_path + '/duplicateOverSurface.mll'
            if cmds.pluginInfo(pluginPath, q=1, l=1) != 1:
                cmds.loadPlugin(pluginPath)
            if mods == 0:
                cmds.duplicateOverSurface(cmds.ls(sl=True, long=True)[0])
            elif mods == 4:
                cmds.duplicateOverSurface(cmds.ls(sl=True, long=True)[0],
                                          rotation=False)
        elif message == "Instant Meshes":
            from ldmt_function import ldmt_instantMeshes
            reload(ldmt_instantMeshes)
            ldmt_instantMeshes.ldmt_show()
        elif message == "Topo Blendshape":
            import geometryWalker.QT.pickWalker_UI as pickWalker_UI
            pickWalker_UI.pickWalkerUI()
        elif message == "Face Transfer":
            import faceTransfer.ui
            faceTransfer.ui.show()
        elif message == "Cloth Transfer":
            from ldmt_function import ldmt_clothTransfer
            reload(ldmt_clothTransfer)
            ldmt_clothTransfer.ldmt_show()
        elif message == "Marvelous Tool":
            from ldmt_function import ldmt_marvelousTool
            ldmt_marvelousTool.ldmt_show()

        # Select Tools
        elif message == "Select Hard Edges":
            from ldmt_function import ldmt_hardEdges
            ldmt_hardEdges.selectHardEdges()
        elif message == "Select UV Borders":
            from ldmt_function import ldmt_UVBorders
            ldmt_UVBorders.selectUVEdgeBorders()
        elif message == "Random Selector":
            from ldmt_function import ldmt_randomSelector
            reload(ldmt_randomSelector)
            ldmt_randomSelector.ldmt_show()
        elif message == "Custom Grouper":
            from ldmt_function import ldmt_customGrouper
            reload(ldmt_customGrouper)
            ldmt_customGrouper.ldmt_show()
        elif message == "N Edge Selector":
            from ldmt_function import ldmt_nEdgeSelector
            reload(ldmt_nEdgeSelector)
            ldmt_nEdgeSelector.ldmt_show()
        elif message == "Toggle Camera Selection":
            if self.ui.btn_toggleCamSel.text() == "Turn Cam Sel On":
                cmds.selectPref(useDepth=1)
                self.ui.btn_toggleCamSel.setText("Turn Cam Sel Off")
            else:
                cmds.selectPref(useDepth=0)
                self.ui.btn_toggleCamSel.setText("Turn Cam Sel On")
        # Generate Tools
        elif message == "Spiral":
            from ldmt_function import ldmt_spiralGen
            reload(ldmt_spiralGen)
            ldmt_spiralGen.spiralGen()
        elif message == "Instance":
            from ldmt_function import ldmt_instanceGen
            reload(ldmt_instanceGen)
            ldmt_instanceGen.instanceGen()
        elif message == "Ribbon":
            from ldmt_function import ldmt_ribbonGen
            from ldmt_function import ldmt_fixReverse
            ldmt_ribbonGen.ribbonGen()
            ldmt_fixReverse.fixReverse()
            ld.showChannelBox()
        elif message == "Tube":
            from ldmt_function import ldmt_tubeGen
            from ldmt_function import ldmt_fixReverse
            sel = cmds.ls(sl=1)
            ldmt_tubeGen.tubeGen(sel[0])
            ldmt_fixReverse.fixReverse()
            ld.showChannelBox()
        elif message == "Seams":
            cmds.undoInfo(swf=False)
            maya_version = cmds.about(version=1)
            if maya_version == '2016':
                pluginPath = ldmt_plugin_path + "/seamsEasy_x64_2016.mll"
            elif maya_version == '2016.5':
                pluginPath = ldmt_plugin_path + "/seamsEasy_x64_2016.5.mll"
            elif maya_version == '2017':
                pluginPath = ldmt_plugin_path + "/seamsEasy_x64_2017.mll"
            elif maya_version == '2018':
                pluginPath = ldmt_plugin_path + "/seamsEasy_x64_2018.mll"
            if cmds.pluginInfo(pluginPath, q=1, l=1) != 1:
                cmds.loadPlugin(pluginPath)
            cmds.undoInfo(swf=True)
            mel.eval("seamsEasy")
        elif message == "Stitches":
            cmds.undoInfo(swf=False)
            maya_version = cmds.about(version=1)
            if maya_version == '2016':
                pluginPath = ldmt_plugin_path + "/seamsEasy_x64_2016.mll"
            elif maya_version == '2016.5':
                pluginPath = ldmt_plugin_path + "/seamsEasy_x64_2016.5.mll"
            elif maya_version == '2017':
                pluginPath = ldmt_plugin_path + "/seamsEasy_x64_2017.mll"
            elif maya_version == '2018':
                pluginPath = ldmt_plugin_path + "/seamsEasy_x64_2018.mll"
            if cmds.pluginInfo(pluginPath, q=1, l=1) != 1:
                cmds.loadPlugin(pluginPath)
            cmds.undoInfo(swf=True)
            mel.eval("stitchEasy")
        elif message == "Rope":
            from ldmt_function import ldmt_rope
            reload(ldmt_rope)
            ldmt_rope.ldmt_show()
        elif message == "Braid":
            from ldmt_function import ldmt_braidGen
            ldmt_braidGen.braidGen()
        elif message == "Edge To Curve":
            from ldmt_function import ldmt_edgeToCurve
            ldmt_edgeToCurve.edgeToCurve()
        elif message == "Ribbon Tools":
            LDRibbonToolsUI_show()
        elif message == "Curve On Mesh":
            startDraw()
        elif message == "Clean Procedure":
            from ldmt_function import ldmt_cleanProcedure
            ldmt_cleanProcedure.cleanProcedure()
        elif message == "Find Description":
            from ldmt_function import ldmt_findXgenDescription
            reload(ldmt_findXgenDescription)
            description = ldmt_findXgenDescription.findXgenDescription()
        elif message == "Align Ribbon UV":
            from ldmt_function import ldmt_alignRibbonUV
            ldmt_alignRibbonUV.xgenRibbonAlignUV()
        # UV Tools
        elif message == "UV Deluxe":
            from ldmt_function.UVDeluxe import uvdeluxe
            uvdeluxe.createUI()
        elif message == "Overlap UV Out":
            from ldmt_function import ldmt_moveOverlapUVOut
            ldmt_moveOverlapUVOut.LD_moveOverlapUVOut()
        elif message == "Overlap UV In":
            from ldmt_function import ldmt_move2rdUVIn
            ldmt_move2rdUVIn.LD_move2rdUVIn()
        elif message == "Quick UV":
            pluginPath = 'Unfold3D'
            if cmds.pluginInfo(pluginPath, q=1, l=1) != 1:
                cmds.loadPlugin(pluginPath)
            quickUVMel = ldmt_function_path + '/quickUV.mel'
            message = 'source "' + quickUVMel + '"'
            mel.eval(message)
        elif message == "Check UV Bleed":
            from ldmt_function import ldmt_checkUVBleed
            reload(ldmt_checkUVBleed)
            ldmt_checkUVBleed.ldmt_show()
        elif message == "Switch UV Set":
            sel = ld.ls(0, 'mesh')
            ld.switchUVSet(sel)
        elif message == "Unfold Seam":
            from ldmt_function import ldmt_unfoldSeam
            ldmt_unfoldSeam.main()
        elif message == "Unwrap Ribbon":
            from ldmt_function import ldmt_unwrapRibbon
            ldmt_unwrapRibbon.unwrapRibbon()
        # Debug Tools
        elif message == "Scene Optimize":
            mel.eval("OptimizeSceneOptions")
        elif message == "Clean Mesh":
            from ldmt_function import ldmt_cleanMesh
            ldmt_cleanMesh.ldmt_show()
        elif message == "Normal Facet":
            from ldmt_function import ldmt_normalFacet
            reload(ldmt_normalFacet)
            ldmt_normalFacet.normalFacet()
        elif message == "Delete Namespace":
            from ldmt_function import ldmt_deleteNamespace
            ldmt_deleteNamespace.deleteNamespace()
        elif message == "Rename":
            melPath = ldmt_function_path + '/patternRename.mel'
            message = 'source "' + melPath + '"'
            mel.eval(message)
            mel.eval('patternRename')
        elif message == "Ungroup":
            sel = cmds.ls(sl=1)
            for i in sel:
                try:
                    cmds.ungroup(i)
                except:
                    pass
        elif message == "Reverse By View":
            from ldmt_function import ldmt_fixReverse
            reload(ldmt_fixReverse)
            ldmt_fixReverse.fixReverse()
        elif message == "Display":
            from ldmt_function import ldmt_display
            reload(ldmt_display)
            ldmt_display.ldmt_show()
        elif message == "Plugin Clean":
            from ldmt_function import ldmt_pluginClean
            ldmt_pluginClean.pluginClean()
        elif message == "Reset Pref":
            from ldmt_function import ldmt_resetPref
            ldmt_resetPref.resetPref()
        # Common Panels
        elif message == "Plugin":
            ldmt_toggleUI.toggleUI('plugin')
        elif message == "Preference":
            ldmt_toggleUI.toggleUI('preference')
        elif message == "HyperGraph":
            ldmt_toggleUI.toggleUI('hypergraph')
            print('hahahah')
        elif message == "Node":
            ldmt_toggleUI.toggleUI('node')
        elif message == "Namespace":
            ldmt_toggleUI.toggleUI('namespace')
        elif message == "Hotkey":
            ldmt_toggleUI.toggleUI('hotkey')
        # File
        elif message == "Quick Export":
            from ldmt_function import ldmt_quickExport
            reload(ldmt_quickExport)
            ldmt_quickExport.ldmt_show()
        elif message == "Open Current Folder":
            from ldmt_function import ldmt_openFolder
            ldmt_openFolder.openFolder()
        # Info
        elif message == "Add Button To Shelf":
            from ldmt_function import addToShelf
            reload(addToShelf)
            addToShelf.addToShelf()
        elif message == "Search Command":
            from ldmt_function import vt_quicklauncher
            vt_quicklauncher.show()
        elif message == "Links":
            os.startfile('https://github.com/xgits/LD_MayaToolbox2')
        elif message == "Help Manual":
            os.startfile('https://github.com/xgits/LD_MayaToolbox2')
        elif message == "Update":
            os.startfile('https://github.com/xgits/LD_MayaToolbox2')
        #Texture Tools
        elif message == "Texture Render":
            from ldmt_function import ldmt_textureRender
            reload(ldmt_textureRender)
            ldmt_textureRender.ldmt_show()
        elif message == "Haircap To UV":
            from ldmt_function import ldmt_haircapToUV
            ldmt_haircapToUV.haircapToUV()
        cmds.undoInfo(cck=1)
        toolMessage = ["Mirror Tool", "Flatten Tool", "Nanomesh", "Instant Meshes", "Cloth Transfer", "Random Selector","Custom Grouper",\
                        "N Edge Selector","Rope","Ribbon Tools","Check UV Bleed","Scene","Clean Mesh","Display","Quick Export",\
                        "Texture Render","Marvelous Tool"]
        if message in toolMessage:
            self.toggleToolBtnByMsg(message)

        ld.msg(message)
        postUsername = userName.replace(' ', '_', 10)
        postCommand = message.replace(' ', '_', 10)
        ldmt_postInfo(postUsername, postCommand)
Пример #40
0
 def getSelectedInOrder():
     if cmds.selectPref(query=True, trackSelectionOrder=True) == False:
         cmds.selectPref(trackSelectionOrder=True)
     return cmds.ls(orderedSelection=True)
Пример #41
0
#AlignZ.py
import maya.cmds as cmds

firstVtxIndexY = 2
secondVtxIndexY = 4

cmds.selectPref(isp=False)

s = cmds.ls(fl=1, os=True)
firstObj = s[0]
secondObj = s[1]
 
vertPos1 = cmds.xform(firstObj, query=True, worldSpace=True, translation=True)
vertPos2 = cmds.xform(secondObj, query=True, worldSpace=True, translation=True)

vtx1X = vertPos1[0]

vtx1Y = vertPos1[1]

vtx1Z = vertPos1[2]


vtx2X = vertPos2[0]

vtx2Y = vertPos2[1]

vtx2Z = vertPos2[2]

cmds.xform(firstObj, a=False, t=(vtx1X, vtx1Y, vtx2Z), ws=True)
Пример #42
0
    def saveLibrary(self):
        """
    This function allows the user to save a library
    """
        #Get save name
        name = self.lineSaveName.text()

        #Rename mesh
        self.workMesh = cmds.rename(self.workMesh, name)

        #Resize mesh to a 1x1x1 bounding volume
        cmds.makeIdentity(self.workMesh, apply=True)
        BoundingBox = cmds.exactWorldBoundingBox(self.workMesh)
        xLength = BoundingBox[3] - BoundingBox[0]
        yLength = BoundingBox[4] - BoundingBox[1]
        zLength = BoundingBox[5] - BoundingBox[2]

        if xLength != 0 and yLength != 0 and zLength != 0:
            # Next we need to find the longest length and scale in down such that the
            # longest length fits within the unit Cube
            if xLength > yLength and xLength > zLength:
                scaleFactor = 1.0 / xLength
            elif yLength > xLength and yLength > zLength:
                scaleFactor = 1.0 / yLength
            elif zLength > xLength and zLength > yLength:
                scaleFactor = 1.0 / zLength

        else:
            cmds.error("Division by zero. The library geo is not 3D")
            return

        cmds.xform(self.workMesh,
                   scale=[scaleFactor, scaleFactor, scaleFactor])
        cmds.select(self.workMesh)
        cmds.move(0, 0, 0, rpr=True, ws=True)
        cmds.makeIdentity(self.workMesh, apply=True)

        #Get ear data
        ExtraData = []
        for i in range(0, 2):
            for j in range(0, 5):
                currentName = self.earLabelList[i][j].text()
                if not currentName:
                    break
                splitName = currentName.split(".vtx")
                if splitName[0] != name:
                    currentName = "%s.vtx%s" % (name, splitName[1])

                ExtraData.append(currentName)

        if not name.strip():
            cmds.warning("Name has not been given. Please give a name")
            return

        #Call the save function
        self.Tubxlibrary.save(name, self.workMesh, earData=ExtraData)

        #Clean Up
        cmds.select(self.workMesh)
        cmds.delete()
        self.workMesh = ""
        cmds.isolateSelect('modelPanel4', state=0)
        ShadingList = [
            'TubxEye', 'TubxNoseBridge', 'TubxNose', 'TubxMouth',
            'TubxMouthLoop', 'TubxForehead', 'TubxEar', 'TubxBackHead',
            'TubxLowerBackHead', 'TubxCheek', 'TubxChin', 'TubxDefault'
        ]
        cmds.select(ShadingList)
        cmds.delete()
        cmds.isolateSelect('modelPanel4', state=0)
        #We also turn back the tracking selection to what it was
        cmds.selectPref(trackSelectionOrder=self.TrackingStatus)