コード例 #1
0
def doSwapAsset(arg=None):
    '''
    Button: Swap For Reference. 
    Swaps current selection for referenced asset.
    '''
    currentImageLibrary = getImageLibrary()
    currentAssetLibrary = getAssetLibrary()
    cmds.namespace(setNamespace=":")
    directory = getCategoryFolder()
    if not directory:
        return
    
    directory = directory.replace(currentImageLibrary, currentAssetLibrary)
    selected = cmds.textField("currentAssetTFD", query=True, text=True)
    if not selected:
        sys.stdout.write("Select an asset.\n")
        return
        
    assetDirectory = selected.partition("_")[0]
    filename = os.path.join(directory, assetDirectory, "%s.ma" % selected)
    if currentAssetLibrary == ddConstants.CHAR_ASSETLIBRARY:
        # due to character naming 'CHAR_character',
        #   assetDirectory needs to be more accurate
        char_patt = re.compile("^([A-Z]{3}_[a-zA-Z]+)\w*$")
        if char_patt.match(selected):
            assetDirectory = char_patt.search(selected).groups()[0]
        filename = os.path.join(directory, assetDirectory, "chesspiece", "published", "%s.ma" % selected)
    
    nodes = getSelectionList(topGrps=False)
    if nodes:
        ddSwapForReference.do(nodes=nodes, filename=filename)
コード例 #2
0
def doSwapReference(arg=None):
    '''Button: Swap For Reference.
    '''
    sys.stdout.write("Swapping for reference... \n")
    currentAssetLibrary = getAssetLibrary()
    nodes = getSelectionList(topGrps=False)
    if nodes:
        ddSwapForReference.do(nodes=nodes, startingDirectory=currentAssetLibrary)