示例#1
0
文件: app.py 项目: myCodeTD/ptAlembic
	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
文件: app.py 项目: myCodeTD/ptAlembic
	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()
示例#3
0
文件: app.py 项目: myCodeTD/ptAlembic
	def applyCacheVersion(self, row, comboBox, arg = None) : 
		listWidget = 'asset_tableWidget'
		version = str(comboBox.currentText())
		assetNames = self.getColumnData(listWidget, self.cacheListCol)
		assetName = assetNames[row]
		cacheGrp = self.cacheData[assetName]['cacheGrp']
		shadeDataFile = self.cacheData[assetName]['shadeDataFile']
		shadeFile = self.cacheData[assetName]['shadeFile']
		abcFile = self.cacheVersions[assetName]['versionKey'][version]


		if os.path.exists(abcFile) : 
			# abcImport.logger.setLevel(DEBUG)
			abcImport.applyCache(cacheGrp, abcFile)

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

		else : 
			logger.debug('abcFile not found %s' % abcFile)
		
		self.refreshUI()
示例#4
0
文件: app.py 项目: myCodeTD/ptAlembic
	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])