예제 #1
0
	def doApplyCache(self) : 
		logger.debug('run apply cache')
		# read asset
		listWidget = 'asset_tableWidget'
		assetNames = self.getTableData(listWidget, self.cacheListCol)
		alwaysRebuild = True


		for assetName in assetNames : 
			abcFile = self.cacheData[assetName]['cachePath']
			cacheGrp = self.cacheData[assetName]['cacheGrp']
			shadeDataFile = self.cacheData[assetName]['shadeDataFile']
			shadeFile = self.cacheData[assetName]['shadeFile']


			if os.path.exists(abcFile) and hook.objectExists(cacheGrp) : 
				abcImport.applyCache(cacheGrp, abcFile, alwaysRebuild)
				logger.debug('set cache %s -> %s' % (cacheGrp, abcFile))

				# automatic assign shade if alembic geo
				if not hook.isReference(cacheGrp) : 
					importShade.applyRefShade(assetName, shadeFile, shadeDataFile)


			else : 
				logger.debug('%s or %s not exists' % (abcFile, cacheGrp))

		self.refreshUI()
예제 #2
0
	def doImportNonCache(self) : 
		# import Non Cache 
		logger.debug('run apply non cache')


		# read asset
		listWidget = 'nonCache_tableWidget'
		nonCacheDataFile = self.setting['nonCacheDataPath']
		data = dict()

		if os.path.exists(nonCacheDataFile) : 
			data = fileUtils.ymlLoader(nonCacheDataFile)

		assetNames = self.getTableData(listWidget, self.nonCacheListCol)

		for each in assetNames : 
			assetName = each 
			if data : 
				exportGrp = data[assetName]['exportGrp']
				filePath = data[assetName]['filePath']

				if not hook.objectExists(exportGrp) : 
					if os.path.exists(filePath) : 
						hook.importFile(filePath)

					else : 
						logger.debug('Path does not exists %s' % filePath)

				else : 
					logger.debug('%s already in the scene' % exportGrp)

			else : 
				logger.error('Error check %s' % nonCacheDataFile)

		self.refreshUI()
예제 #3
0
	def checkDataStatus(self) : 

		if self.setting : 
			# check camera
			cameraPath = self.setting['cameraPath']
			shotCameraName = self.setting['shotCameraName']

			camMessage = ['No Camera File', self.xIcon]
			if os.path.exists(cameraPath) : 
				self.ui.importCamera_pushButton.setEnabled(True)
				camMessage = ['Camera File Exists', self.okIcon]

			sceneCamMessage = ['No Cam', self.xIcon]
			if hook.objectExists(shotCameraName) : 
				self.ui.importCamera_pushButton.setEnabled(False)
				sceneCamMessage = ['Camera OK', self.okIcon]


			# append data 
			self.statuses.append(camMessage)
			self.statuses.append(sceneCamMessage)

			# set status UI
			self.ui.status_listWidget.clear()
			self.addToolStatus(self.statuses)
예제 #4
0
	def setNonCacheList(self) : 
		# read data 
		if self.setting : 
			nonCacheDataFile = self.setting['nonCacheDataPath']
			widget = 'nonCache_tableWidget'
			self.clearTable(widget)

			if os.path.exists(nonCacheDataFile) : 
				data = fileUtils.ymlLoader(nonCacheDataFile)

				row = 0
				height = 20
				for each in data : 
					assetName = each 
					exportGrp = data[each]['exportGrp']
					filePath = data[each]['filePath']
					status = 'No'
					statusIcon = self.xIcon

					if hook.objectExists(exportGrp) : 
						status = 'Yes'
						statusIcon = self.okIcon

					self.insertRow(row, height, widget)
					self.fillInTable(row, self.nonCacheListCol, assetName, widget, [0, 0, 0])
					self.fillInTableIcon(row, self.nonCahceInSceneCol, status, statusIcon, widget, [0, 0, 0])

					row += 1 
예제 #5
0
	def findCurrentAbcVersion(self, assetName) : 
		# find current version 

		cacheGrp = self.cacheData[assetName]['cacheGrp']
		if hook.objectExists(cacheGrp) : 
			alembicNode = hook.getAlembicNode(cacheGrp)

			if alembicNode : 
				currentAbcFile = hook.getAlembicPath(alembicNode[0])
				currentAbcVersion = os.path.dirname(currentAbcFile).split('/')[-1]

				return currentAbcVersion
예제 #6
0
	def doRemoveCacheAsset(self) : 
		# list
		listWidget = 'asset_tableWidget'
		assetNames = self.getTableData(listWidget, self.nonCacheListCol)
		allRefs = hook.getAllReference()

		if self.cacheData : 
			for each in assetNames : 
				namespace = each 
				cacheGrp = self.cacheData[each]['cacheGrp']
				shadeFile = self.cacheData[each]['shadeFile']

				if hook.objectExists(cacheGrp) : 
					alembicNode = hook.getAlembicNode(cacheGrp)

					if hook.objectExists(cacheGrp) : 
						isRef = hook.isReference(cacheGrp)
						hook.delete(alembicNode)

						if isRef : 
							hook.removeReference(cacheGrp)

						else : 
							# delete upper level == Rig_Grp
							rigGrp = hook.getParent(cacheGrp)

							if rigGrp : 
								hook.delete(rigGrp[0])

								if shadeFile in allRefs : 
									namespaceShade = hook.getNamespace(shadeFile)
									hook.removeReferenceByPath(shadeFile)
									hook.removeNamespace(namespaceShade)

						hook.removeNamespace(namespace)

			hook.deleteUnUsedNodes()

		self.refreshUI()
예제 #7
0
	def doRebuildAsset(self) : 
		# read asset
		listWidget = 'asset_tableWidget'

		assetNames = self.getTableData(listWidget, self.cacheListCol)
		assetPaths = self.getTableData(listWidget, self.assetPathCol)

		i = 0 
		for i in range(len(assetNames)) : 
			assetName = assetNames[i]
			assetPath = assetPaths[i]
			cacheGrp = self.cacheData[assetNames[i]]['cacheGrp']

			if os.path.exists(assetPath) : 
				if not hook.objectExists(cacheGrp) : 
					hook.createReference(assetName, assetPath)

		self.refreshUI()
예제 #8
0
	def doImportCamera(self) : 
		cameraPath = self.setting['cameraPath']
		cameraInfoPath = self.setting['cameraInfoPath']
		shotCameraName = self.setting['shotCameraName']
		cameraInfoPath = self.setting['cameraInfoPath']

		if not hook.objectExists(shotCameraName) : 
			if os.path.exists(cameraPath) : 
				hook.importFile(cameraPath)
				hook.fixSequencer()

		if os.path.exists(cameraInfoPath) : 
			range = fileUtils.ymlLoader(cameraInfoPath)

			if range : 
				currentShot = self.shotInfo.getShotName()
				min = range[currentShot]['startFrame']
				max = range[currentShot]['endFrame']
				hook.setShotRange(min, max)

		self.checkDataStatus()
예제 #9
0
	def setCacheList(self) : 
		# self.cacheData from def refreshUI
		# clear table 
		widget = 'asset_tableWidget'
		self.clearTable(widget)

		self.statuses = []
		assetMissing = []

		if self.cacheData : 
			
			# fix variable 
			row = 0 
			height = 20
			
			for each in self.cacheData.keys() : 

				# set data 
				assetName = each 
				iconPath = self.xIcon
				inScene = 'No'
				color = [120, 0, 0]
			
				status = 'Not Match'
				statusIcon = self.xIcon
				statusColor = [60, 0, 0]

				# This asset path will return absolute path 
				# ex. P:/Lego_Friends2015/asset/3D/character/main/frd_stephanieSchool/ref/frd_stephanieSchool_Cache.ma
				# this tool will override this path to selected cache version from UI -> Render / Cache
				# to modify --> O:\studioTools\maya\python\tool\ptAlembic\abcExport.py func getShaderPath()

				assetPath = self.cacheData[each]['assetPath']
				lod = str(self.ui.assetVersion_comboBox.currentText())
				print assetPath

				# comment this line to use default asset path 
				# assetPath = assetPath.replace('Cache.ma', lod)

				# check asset exists 
				if os.path.exists(assetPath) : 
					color = [0, 120, 0]

				else : 
					self.statuses.append(['Missing %s' % assetName, self.xIcon])
					assetMissing.append(assetName)

				# check asset exists in scene 
				cacheGrp = self.cacheData[each]['cacheGrp']
				if hook.objectExists(cacheGrp) : 
					inScene = 'Yes'
					iconPath = self.okIcon

					isRef = hook.isReference(cacheGrp)

					if isRef : 
						inScene = 'Reference'
						iconPath = self.refIcon

					else : 
						inScene = 'Alembic'
						iconPath = self.abcIcon

				# raed cache version from yml file
				cachePath = self.cacheData[each]['cachePath']
				publishVersion = os.path.dirname(cachePath).split('/')[-1]

				# check existing cache version 
				cacheLod = '-'
				currentAbcVersion = '-'

				if assetName in self.cacheVersions.keys() : 
					currentAbcVersion = self.findCurrentAbcVersion(assetName)


				# set status
				if not currentAbcVersion : 
					status = 'Node not found'
					statusColor = [120, 100, 0]
					statusIcon = self.infoIcon

				if currentAbcVersion == publishVersion : 
					status = 'Good'
					statusIcon = self.okIcon
					statusColor = [0, 0, 0]


				# check asset hierarchy 
				assetDataPath = self.setting['assetDataPath']
				assetDataFile = '%s/%s.yml' % (assetDataPath, assetName)
				result = pipelineTools.checkHierarchyData(cacheGrp, assetDataFile)

				hStatus = 'Good'
				hStatusIcon = self.okIcon 

				if result : 
					hStatus = 'Warning'
					hStatusIcon = self.xIcon

				# shade section
				sStatus = 'N/A'
				sStatusIcon = ''

				if hook.objectExists(cacheGrp) : 
					isRef = hook.isReference(cacheGrp)

					if not isRef : 
						allRefs = hook.getAllReference()
						shadeFile = self.cacheData[each]['shadeFile']
						
						if shadeFile in allRefs : 
							sStatus = 'OK'
							sStatusIcon = self.okIcon

						else : 
							sStatus = 'Missing'
							sStatusIcon = self.xIcon

				# cache version by striping end of the asset path (Cache)
				cacheLod = assetPath.split('.')[0].split('_')[-1]

				# set cache list UI
				self.insertRow(row, height, widget)
				self.fillInTable(row, self.cacheListCol, assetName, widget, color)
				self.fillInTableIcon(row, self.inSceneCol, inScene, iconPath, widget, [0, 0, 0])
				self.fillInTable(row, self.lodCol, cacheLod, widget, [0, 0, 0])
				self.fillInTableIcon(row, self.statusCol, status, statusIcon, widget, statusColor)
				self.fillInTable(row, self.publishVersionCol, publishVersion, widget, [0, 0, 0])
				self.fillInTable(row, self.assetPathCol, assetPath, widget, [0, 0, 0])
				self.fillInTable(row, self.cacheGrpCol, cacheGrp, widget, [0, 0, 0])
				self.fillInTableIcon(row, self.shadeCol, sStatus, sStatusIcon, widget, [0, 0, 0])
				self.fillInTableIcon(row, self.hierarchyCol, hStatus, hStatusIcon, widget, [0, 0, 0])

				
				# add comboBox to current version
				# get all versions 
				comboBox = QtGui.QComboBox()
				versionItems = self.cacheVersions[assetName]['versions']
				comboBox.addItems(versionItems)

				# set current version 
				if currentAbcVersion in versionItems : 
					index = versionItems.index(currentAbcVersion)
					comboBox.setCurrentIndex(index)



				# set signal 
				comboBox.currentIndexChanged.connect(partial(self.applyCacheVersion, row, comboBox))
				# comboBox.currentIndexChanged.connect(lambdapartial(self.applyCacheVersion, index, row))
				self.ui.asset_tableWidget.setCellWidget(row, self.currentVersionCol, comboBox)

				row += 1

			if not assetMissing : 
				self.statuses.append(['Asset OK', self.okIcon])