Thanks for taking a moment to read this! So, as the title of my post implies, I'm trying to import some obj files into Maya, but I get the following error message when I try running my script:
Error: line 1: TypeError: file <maya console> line 8: object of type
'NoneType' has no len()
My script is listed below:
import maya.cmds as cmds
pathOfFiles = "/This PC/Desktop/Facial Rigging Blendshapes/"
fileType = "obj"
files = cmds.getFileList(folder=pathOfFiles, filespec='*.%s' % fileType)
if len(files) == 0:
cmds.warning("No files found")
else:
for f in files:
cmds.file(pathOfFiles + f, i=True)
Thanks again for taking the time to read this! Cheers!
The problem lies in the path. If cmds.getFileList()
get's a non existing path, it returns None
, not an empty list. So I suggest to check if the directory exists or check for None
result. I can reproduce your problem if use this code:
pathOfFiles = "C:/Userss"
files = cmds.getFileList(folder=pathOfFiles)
Where "C:/Userss" does not exist.