Python Maya question


I am a complete beginner in python so this might be something basic but so far it just seems really weird to me…

anyway this is my script so far. I am trying to copy the global reflection and refraction node trees over to selected shaders while also renaming them removing the global part and adding the name of the shader I am copying it to.

The weird part is that if I run through everything except the connections it works but if I run through the whole script the renaming only renames the first node. So it is like something is up with my loop but only when I also try to run with the following parts. Any tips are appreaciated:)

import maya.cmds as mc


for each in shaders:
    #duplicate refl/rough networks
    duplicateReflShd = mc.duplicate ('remapValue_Srf_Refl_global', 'remapValue_Srf_Rough_global', un=True) 
    #rename reflshaders
    for x in duplicateReflShd:
        name = x.split("_")
        newname = name + "_" + each
        mc.rename(x, newname)
        #print newname     
        # connect refl shader to surface shader
	mc.connectAttr ("remapValue_Srf_Refl_" + each + ".outValue", each + ".refl_weight", force=True)
	mc.connectAttr ("remapValue_Srf_Rough_" + each + ".outValue", each + ".refl_roughness", force=True)


Hi buddy, just try looping from 5-8 line and you are all good to go. Hope this helps :slight_smile:



Hi buddy, a quick update, did it work?




I really appreciate your work

You can try connecting from 5 to 8 lines and you are all suitable to go.

Softpulse Infotech


Really a problem with those lines


I have been looking for this since a very long time.


Keep sharing such Informative posts.


i will keep my eye on this,