pythontexturesmayashading

Locked file texture in Maya shadingNode


I am getting some strange results here using the shadingNode, whenever I create a file node through Python in Maya I get the color space locked and the color space drop menu greyed out.

fileNode = cmds.shadingNode( "file", asTexture=True, name="dispMap" ) 

Please see image attached, however I get the usual expected result when I create the file node from the create shader tab in Hypershade.

Here's an image


Solution

  • You need to re-apply the Input Color Space Rules.

    import maya.cmds as cmds
    import pymel.core as pm
    
    shader = cmds.shadingNode( 'anisotropic', asShader=True )
    file_node = cmds.shadingNode( 'file', asTexture=True, name="dispMap" )
    # file = ( '/Users/me/Desktop/texture.jpg' )
    
    shading_group = cmds.sets( renderable=True, noSurfaceShader=True, empty=True )
    cmds.connectAttr( '%s.outColor' %shader , '%s.surfaceShader' %shading_group )
    cmds.connectAttr( '%s.outColor' %file_node, '%s.color' %shader )
    
    cmds.polySphere( n='mySphere', radius=5, sx=40, sy=30 )
    cmds.select( 'mySphere', visible=True )
    cmds.hyperShade( assign=shader )
    
    colMgmtGlob = pm.PyNode( 'defaultColorMgtGlobals' )
    
    for f in pm.ls( type='file' ):
        colMgmtGlob.cmEnabled >> f.colorManagementEnabled
        colMgmtGlob.configFileEnabled >> f.colorManagementConfigFileEnabled
        colMgmtGlob.configFilePath >> f.colorManagementConfigFilePath
        colMgmtGlob.workingSpaceName >> f.workingSpace