コード例 #1
0
def loadMaterials(control, selID, *args):
    ''' populate and highlight list of materials based on selected material ID. '''
    # control is for THIS control. selID is the currently selected item of the mat ID selector.
    # first, get all materials and populate the control. then highlight materials with the matching matID.
    selID = int(selID)
    sgs = cmds.ls(type='shadingEngine')
    mats = []
    cmds.textScrollList(control, e=1, ra=1)
    for sg in sgs:
        try:
            mat = cmds.listConnections(sg + '.surfaceShader')
            mats.extend(mat)
        except TypeError:
            pass
    try:
        mats = natSort.natsorted(mats)
    except TypeError:
        # probably empty for whatever reason
        pass
    for mat in mats:
        #cmds.textScrollList(control,e=1,a=mat)
        matID = 0
        try:
            matID = cmds.getAttr(mat + '.vrayMaterialId')
            cmds.textScrollList(control, e=1, a=mat)
            if matID == selID:
                cmds.textScrollList(control, e=1, si=mat)
        except (TypeError, ValueError):
            pass
コード例 #2
0
ファイル: toggleVraySubdiv.py プロジェクト: tws0002/gs-code
def popSubdivLists(notSubList,subList,retards,*args):
    subdivEnabledGeo = []
    notSubdivGeo = []
    geoList = [f for f in cmds.ls(type='mesh') if cmds.getAttr(f+'.intermediateObject') == 0]
    subdivGeo = [f for f in geoList if cmds.attributeQuery('vraySubdivEnable',exists=1,node=f) == True]
    subdivEnabledGeo = [f for f in subdivGeo if cmds.getAttr(f+'.vraySubdivEnable') == 1]
    notSubdivGeo = [f for f in geoList if f not in subdivEnabledGeo and f not in retards]
    subdivEnabledGeo = natSort.natsorted(subdivEnabledGeo)
    notSubdivGeo = natSort.natsorted(notSubdivGeo)
    subdivEnabledGeo.extend(retards)
    cmds.textScrollList(subList,e=1,ra=1)
    cmds.textScrollList(notSubList,e=1,ra=1)
    for i in subdivEnabledGeo:
        cmds.textScrollList(subList,e=1,a=i)
    for i in notSubdivGeo:
        cmds.textScrollList(notSubList,e=1,a=i)
    return notSubdivGeo,subdivEnabledGeo
コード例 #3
0
def loadMatIDs(control, *args):
    ''' populate list of material IDs for the relationship editor. '''
    indices, hiIndex, vropIndices = getIndexInfo(0)
    cmds.textScrollList(control, e=1, ra=1)
    try:
        indices = natSort.natsorted(indices)
    except TypeError:
        # probably empty, natSort doesn't like this
        pass
    for i in indices:
        cmds.textScrollList(control, e=1, a=i)
コード例 #4
0
def refreshCallback(matsControl, idControl, matsMatchControl, indexControl):
    # deselect everything, reload all textScrollLists
    # first the material list.
    matsList = []
    sgList = cmds.ls(type='shadingEngine')
    for sg in sgList:
        try:
            matsList.extend(cmds.listConnections(sg + '.surfaceShader'))
        except TypeError:
            pass
    matsList = list(set(matsList))
    # make a pruned list of materials with no matID.
    matsNoID = [
        m for m in matsList
        if cmds.attributeQuery('vrayMaterialId', node=m, ex=1) == 0
    ]
    matsWithID = [
        m for m in matsList
        if cmds.attributeQuery('vrayMaterialId', node=m, ex=1) == 1
    ]
    try:
        matsNoID = natSort.natsorted(matsNoID)
    except TypeError:
        pass
    try:
        matsWithID = natSort.natsorted(matsWithID)
    except TypeError:
        pass
    # populate matsControl and matsMatchControl.
    cmds.textScrollList(matsControl, e=1, ra=1)
    cmds.textScrollList(matsMatchControl, e=1, ra=1)
    for m in matsNoID:
        cmds.textScrollList(matsControl, e=1, a=m)
    for m in matsWithID:
        cmds.textScrollList(matsMatchControl, e=1, a=m)
    # repopulate mat IDs list.
    loadMatIDs(idControl)
    # reload latest index control
    indices, hiIndex, vropIndices = getIndexInfo()
    cmds.textField(indexControl, e=1, tx=(hiIndex + 1))
コード例 #5
0
def filterFolderList(filter, control, *args):
    # print 'debug: filterFolderList using filter %s for control %s' % (filter,control)
    # for the import version UI. stocks the folder list based on the original filter.
    dataPath = os.path.join(cmds.workspace(q=1, fn=1), 'data/animExport/')
    versionList = [
        f for f in os.listdir(dataPath)
        if os.path.isdir(os.path.join(dataPath, f))
    ]
    # now match each of these versions against the filter.
    filteredList = versionList
    if filter != '':
        filteredList = [
            f for f in versionList if f.upper().find(filter.upper()) != -1
        ]
    cmds.textScrollList(control, e=1, ra=1)
    filteredList = natSort.natsorted(filteredList)
    for f in filteredList:
        cmds.textScrollList(control, e=1, a=f)