Hi,
1) I need to copy images from local to central thru a 3d appl. In doing so i m using threads to ensure that maya does not freeze. Now the case is for each image that is copied there is multiple sizes of this image that has to be copied. In other words, multithreads. or sub thread. ( What do you say ).
2) Only the first image get copied. The second one does not. Although it shows that the control has read the second image ( in case there are two images)
def localToCentral(fileName):
global oldImageBaseName
global thread2
global thread1
shutil.copy(fileName,(trueResDir + oldImageBaseName))
imageDimension = utils.executeInMainThreadWithResult( getSize, fileName)
print imageDimension,' imageDimension ',fileName, ' fileName\n '
imageSize = imageDimension[0] * imageDimension[1]
if (imageSize >= 4096*4096):
for z in range(0,4):
dictNumber = eval("listSize[\""+str(z)+"\"]")
thread2 = threading._start_new_thread(doLoop4096, (int(dictNumber), fileName))
elif (imageSize >= 2048*2048 and imageSize < 4096*4096) or (imageSize == 2048*2048):
for z in range(0,3):
dictNumber = eval("listSize[\""+str(z)+"\"]")
thread2 = threading._start_new_thread(doLoop4096, (int(dictNumber), fileName))
elif (imageSize >= 1024*1024 and imageSize < 2048*2048) or (imageSize == 1024*1024):
for z in range(0,2):
dictNumber = eval("listSize[\""+str(z)+"\"]")
thread2 = threading._start_new_thread(doLoop4096, (int(dictNumber), fileName))
elif (imageSize >= 512*512 and imageSize < 1024*1024) or (imageSize == 512*512):
for z in range(0,1):
dictNumber = eval("listSize[\""+str(z)+"\"]")
thread2 = threading._start_new_thread(doLoop4096, (int(dictNumber), fileName))
elif (imageSize >= 256*256 and imageSize < 512*512):
z = 0
dictNumber = eval("listSize[\""+str(z)+"\"]")
thread2 = threading._start_new_thread(doLoop4096, (int(dictNumber), fileName))
elif (imageSize <= 256*256): # presuming width is always greater than height
mm.eval("warning \"image size less than minumum of 256\"")
def CopyCentral(source, destination, size):
shutil.copy(source, destination)
x = os.system('imconvert -resize ' + size + ' ' + (destination) + ' ' + (destination))
def doLoop4096(z,source):
dest = eval("_"+ str(z) + "Dir") + oldImageBaseName
destination = dest.encode('ascii')
size = str(str(z) + "x" + str(z))
CopyCentral(source, destination, size)
def getSize(fileName):
return cmds.getImageSize(fileName)
initia() # set initial values
for file in range(0, len(fileArrayOrigName)):
temp_var_01 = fileArrayOrigName[file]
temp_var_02 = temp_var_01.encode('ascii')
thread1 = threading._start_new_thread(localToCentral,(temp_var_02,))