Python in Maya - script for applying a material?

674 views
Skip to first unread message

Kate Sendall

unread,
Aug 14, 2015, 11:55:37 AM8/14/15
to Python Programming for Autodesk Maya
Hi! I'm trying to assign a material to an object in the script editor using python. I've managed to assign the object to maya_material_x, but can't seem to find a way to make it one of the presets! Help would be greatly appreciated. :)

def applyMaterial():
    myShader = mc.shadingNode('mia_material_x', asShader=True)
    mc.select('myStep*')
    mc.hyperShade(assign = myShader) 


Simple really, don't know why I can't figure it out. XD

Kate

f.michal

unread,
Aug 14, 2015, 11:58:30 AM8/14/15
to python_in...@googlegroups.com
Pardon MEL, but that's what I have now :)

global proc mfNewShaderForSL()
{
    string $sl[]= `ls -sl -l`;
    for($o in $sl)
    {
        string $SG = `sets -renderable true -noSurfaceShader true -empty`;
        string $shader = `shadingNode -asShader lambert`;
        connectAttr -f ($shader + ".outColor") ($SG + ".surfaceShader");
        select $o;
        //this is what you need !
        sets -e -forceElement $SG;
    }
}

W dniu 2015-08-14 o 17:55, Kate Sendall pisze:
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/25b05c27-2e35-4bec-abc5-f4c19dc2a40b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kurian O.S

unread,
Aug 14, 2015, 2:03:05 PM8/14/15
to python_in...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages