Пример #1
0
	def importForAsset(self, asset, area = 1,customNamespace = None, referenceAsset = True, assetInShotFolder = False, shot = None, useDefaultName = False ):
		"""import cache and assign to asset"""
		#reference render asset
		#connect cache to objects
		if referenceAsset:
			if assetInShotFolder:
				assetNewPath = asset.areaPath( area ).copy( shot.assetsPath + asset.areaPath( area ).path.split( 'Assets/' )[-1] )
				nodes = assetNewPath.reference( customNamespace, useDefaultName )
			else:
				nodes = asset.areaPath( area ).reference( customNamespace, useDefaultName )
			mshs = mn.ls( nodes, typ = 'mesh', ni = True, l = True )
		else:
			if useDefaultName:
				nodes = asset.areaPath( area ).imp( None )
			else:
				nodes = asset.areaPath( area ).imp( customNamespace )
			if nodes:
				mshs = mn.ls( nodes, typ = ['mesh','nurbsCurve'], ni = True, l = True )
			else:
				mshs = mn.ls( customNamespace + ':*', typ = ['mesh','nurbsCurve'], ni = True, l = True )
			#filter meshes
		mshs.select()
		abcNode = self.imp( mode = 'import', connect = "/", createIfNotFound = True )
		if USE_EXOCORTEX:
			mshsAttrDict = {}
			for m in mshs:
				his = [a for a in mn.listHistory( m, f = True ) if a.type == 'mesh']
				if len(his) == 2:
					attrs = ['castsShadows', 'receiveShadows', 'motionBlur','primaryVisibility','smoothShading','visibleInReflections','visibleInRefractions','doubleSided','opposite','aiSelfShadows','aiOpaque','aiVisibleInDiffuse','aiVisibleInGlossy','aiMatte','aiSubdivType','aiSubdivIterations','aiSubdivAdaptiveMetric','aiSubdivUvSmoothing','aiSubdivSmoothDerivs','aiDispHeight','aiDispZeroValue','aiDispAutobump','aiStepSize']
					for a in attrs:
						if his[0].attr(a).exists:
							his[1].attr( a ).v = his[0].attr( a ).v
Пример #2
0
	def getTexturesForSelection(self):
		"""docstring for getTexturesForSelection"""
		textures = []
		for n in mn.ls(sl = True):
			for t in mn.listHistory( n.shader ):
				if t.type == 'file':
					textures.append( t )
		return textures
Пример #3
0
def reAssignMaterial():
	"""docstring for reAssignMaterial"""
	meshesWithHistory, meshesWithMaterialPerFace = isMeshWithHistory()
	for n in meshesWithMaterialPerFace:
		his = mn.listHistory( n )
		for h in his:
			if h.type == 'shadingEngine':
				n()
				mc.hyperShade( assign = h.a.surfaceShader.input )
Пример #4
0
def reAssignMaterial():
    """docstring for reAssignMaterial"""
    meshesWithHistory, meshesWithMaterialPerFace = isMeshWithHistory()
    for n in meshesWithMaterialPerFace:
        his = mn.listHistory(n)
        for h in his:
            if h.type == 'shadingEngine':
                n()
                mc.hyperShade(assign=h.a.surfaceShader.input)
Пример #5
0
	def replace(self):
		"""docstring for replace"""
		if not USE_EXOCORTEX:
			mn.Nodes( mn.ls( mn.ls(sl = True)[0].namespace.name[1:] + ':*', typ = ['mesh'] )).select()
			self.imp( mode = 'import', connect = "/", createIfNotFound = True )
		else:
			sel = mn.ls( sl = True )
			his = mn.listHistory(sel[0])
			if his:
				caFileNode = [n for n in his if n.type == 'ExocortexAlembicFile']
				if caFileNode:
					caFileNode[0].a.fileName.v = self.path
Пример #6
0
def isMeshWithHistory():
	"""return meshes that has history or material assigned by face"""
	withAssignedMaterialByFace = []
	withHistory = []
	for n in mn.ls( typ = 'mesh', ni = True ):
		his = mn.listHistory( n )
		if not len( his ) == 1:
			if any( 'groupId' in h.name for h in his ):
				withAssignedMaterialByFace.append( n )
				print 'This mesh has the material assigned by faces', n.name, his
				if len( his ) == 3:
					continue
			if any( 'shaveHair' in h.type for h in his ):
				print 'This mesh is related with Shave and Hair cut', n.name, his
				continue
			withHistory.append( n )
	return withHistory, withAssignedMaterialByFace
Пример #7
0
def isMeshWithHistory():
    """return meshes that has history or material assigned by face"""
    withAssignedMaterialByFace = []
    withHistory = []
    for n in mn.ls(typ='mesh', ni=True):
        his = mn.listHistory(n)
        if not len(his) == 1:
            if any('groupId' in h.name for h in his):
                withAssignedMaterialByFace.append(n)
                print 'This mesh has the material assigned by faces', n.name, his
                if len(his) == 3:
                    continue
            if any('shaveHair' in h.type for h in his):
                print 'This mesh is related with Shave and Hair cut', n.name, his
                continue
            withHistory.append(n)
    return withHistory, withAssignedMaterialByFace