Python script for MAYA working but getting a few errors which I am unable to understand


#1

This is my script

import maya.cmds as cmds
#Creating RedshiftMaterial
rsMtl = cmds.shadingNode("RedshiftMaterial", asShader=True)
rsSG = cmds.sets(name="rsSurfaceShader",renderable=True,noSurfaceShader=True,empty=True)
cmds.connectAttr("%s.outColor"%rsMtl,"%s.surfaceShader"%rsSG)


    #Creating FileNode
    diffFile= cmds.fileDialog2(caption="Open Diffuse Map",fm=4)
    for tex in diffFile:
        cmds.select(clear=True)
        texture = mel.eval('createRenderNodeCB -as2DTexture "" file ""')
        cmds.setAttr(texture+".fileTextureName",tex, type="string")

    conList=cmds.listAttr(rsMtl)
    for t in conList:
        #getDiff= cmds.getAttr("%s"%rsMtl+".diffuse_color")
        cmds.connectAttr(texture+".outColor","%s"%rsMtl+".diffuse_color")
and I get these errors in specific
    // Warning: 'file1.outColor' is already connected to 'rsMaterial1.diffuse_color'. //
    // Error: RuntimeError: file <maya console> line 19: Maya command error //
    // Error: file: C:/Program Files/Autodesk/Maya2019/scripts/AETemplates/AEfileTemplate.mel line 649: No object matches name: file3.uvTileProxyDirty //
    // Error: file: C:/Program Files/Autodesk/Maya2019/scripts/AETemplates/AEfileTemplate.mel line 649: Error evaluating argument at position 1 in procedure "createGeneratePreviewButton". //
    // Error: file: C:/Program Files/Autodesk/Maya2019/scripts/AETemplates/AEfileTemplate.mel line 468: Object 'textureUvTilingGeneratePreviewButton' not found. //
    // Performing Auto-Save at 2019/09/25 15:30:40: //
    //    master file:    __AUTO-SAVE__untitled.mb //
I am fairly new to Py scripting and wanted to make a tool where once you run this script a shader is created in the background and the user just has to redirect the dialogue box to the respective texture files.

Thanks :slight_smile: