# Definition of Class to scan given Maya Ascii File
import re
import os
class mayaFileScanBaseClass:
def __init__(self,filename):
self.filename = filename
def fileScan(self):
'''Scans File for 'createNode' and looks for shading nodes'''
fid = open(self.filename)
output = []
epnames=['Prefix_']
for line in fid:
if line.startswith('createNode'):
words = line.split(' ')
nodeTypes = ['lambert','shadingEngine','materialInfo','bump2d',\
'bump3d','blinn','file','place2dTexture','place3dTexture',\
'anisotropic','rampShader','phong','ramp','blendColors',\
'surfaceLuminance','clearCoat','layeredTexture','samplerInfo']
for n in nodeTypes:
if words[1]==n:
names = line.split('-n ')
name = names[1].split('"')
namechk = name[1].replace(words[1],'')
if(not namechk.islower()):
output.append(name[1])
else:
i = 0
for j in epnames:
if(name[1].startswith(j)):
i = 1
break
if i==0:
output.append(name[1])
else:
if len(re.findall('\W',name[1])) > 0:
output.append(name[1])
fid.close()
return output
def fileScan_ftn(self):
'''Scans File for ftn nodeType and does texture\
name checking and check if texture file exists '''
fid = open(self.filename)
paths = []
for line in fid:
if re.compile('.ftn').search(line,1):
path = line[32:-3]
paths.append(path)
return paths
No comments:
Post a Comment