Hello all,
I recently started learning pymel and currently I want to check if a filepath is a folder or a file.
so i used the "filetest" command. However this did not work as I expected it.
if i do this:
var1 = "C:/Program Files/Autodesk/Maya2011/"
mel.filetest(var1, d=True)
# Error: line 1: Invalid call to "filetest".
# Check number and types of arguments expected by the procedure. #
I think I am just missing something but i have tried almost every combination i can think of.
if i do it the mel way then maya instantly crashes
1
2
3
4
var1= "C:/Program Files/Autodesk/Maya2011/"
mel.eval("filetest -d "+var1)
So i thought it could be because i use a pymel variable in a mel command.
So I tried to convert the pymel variable to a mel variable but that does not happen on runtime for some reason.
For example when doing this :
def varTest():
var1= "C:/Program Files/Autodesk/Maya2011/"
if mel.eval("$singleFileLocationMel = `python(\"var1\")`; filetest -d $singleFileLocationMel;"):
print ' its a folder'
else:
print 'its not a folder'
varTest()
# MelError: Error during execution of MEL script: line 1: name 'var1' is not defined
So it can not find the variable because its not defined ... which is wierd in my opinion since i have just defined it.
Sometimes it does work but then it only takes the variable that is already in the memory.
Does anyone have any idea how to get that filetest to work ?
Any suggestion would be most appriciated.
Thanks,
Jan