Python Maya Error. Help!

Skip to first unread message

Juan Pablo

Nov 16, 2016, 7:28:50 PM11/16/16
to sydneypython

I have this script in Python which I'm running into a maya file from a command line:

import maya.standalone
import maya.cmds as cmds
from maya import cmds
import maya.mel as mel
import glob

def importFile(i):
    cmds.file(i, i=True, groupReference=True, groupName="myobj")

def materialFile():
    if cmds.objExists('Panel*'):"Panel*", replace=True)
        myMaterial = "BlueGlass"
        cmds.sets( e=True, forceElement= myMaterial + 'SG' ) 

    if cmds.objExists('Body*'):"Body*", replace=True)
        myMaterial3 = "Silver"
        cmds.sets( e=True, forceElement= myMaterial3 + 'SG' )

But I get this error when I try to run the batch file:

File "/Users/../Scripts/", line 23, in materialFile
        cmds.sets( e=True, forceElement= myMaterial + 'SG' ) 
TypeError: No object matches name: BlueGlassSG

In the Hypershade, the shader BlueGlass is connected to a shader group (SG) with the same name BlueglassSG and the script works from the UI inside maya.

Do I need to load a plugin or something in the script to make it run in the batch file?

Xuanyi Chew

Nov 16, 2016, 7:31:19 PM11/16/16
to sydneypython
Released from spamqueue. Anyone with maya experience?

Xuanyi Chew
@chewxy on Twitter

You received this message because you are subscribed to the Google Groups "sydneypython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

Ben De Luca

Nov 17, 2016, 1:50:01 AM11/17/16
Where is the whole script? 

The maya file should trigger loading any plugins you need. If you save out as maya asci you will see the requirements. 
But there are some parts of the system that only become live if you have the UI available. 

If you start a normal maya session with your code as a script does it run?

Reply all
Reply to author
0 new messages