To the poor souls that have this problem, where they load diffuse maps with alpha but the alpha is not connected, the following python snippet does the magic:
#newnodes is a list of nodes that you want to look for textures/materials, for example all nodes created while importing your model
filenodes = cmds.ls(newnodes, exactType='file')
for fnode in filenodes:
if cmds.getAttr(fnode+'.fileHasAlpha'):
conns = cmds.listConnections(fnode, connections=True)
matnode = None
for i in range(len(conns)):
if '.outColor' in conns[i]:
#assert (matnode == None)
matnode = conns[i+1]
break
if matnode != None:
cmds.connectAttr( fnode+'.outTransparency', matnode+'.transparency', force=True)Essentially, all it does is looks into the nodes created by importing your model for file nodes and checks their connections. If they have an outColor connection, they also try to apply an outTransparency. And that's it, really.