import xgenm as xg
import xgenm.xgGlobal as xgg
import xgenm.XgExternalAPI as xge
import os
import maya.cmds as cmds
import os
import maya.cmds as cmds
import xgenm.xmaya.xgmExternalAPI as xgmExternalAPI
import xgenm.XgExternalAPI as xge
import xgenm.xgGlobal as xgg
if xgg.Maya:
import maya.mel as mel
strCurrentScene = cmds.file( q=True, sn=True )
strSceneName = ""
if strCurrentScene:
strScenePath = os.path.dirname( strCurrentScene )
strSceneFile = os.path.basename( strCurrentScene )
strSceneName = os.path.splitext( strSceneFile )[0];
abcFolderPath = strScenePath.replace("scenes","") + "cache/alembic"
abcFiles = os.listdir(abcFolderPath)
def ExportBatchesAnim():
ExportStartFrame = cmds.getAttr("defaultRenderGlobals.startFrame")
ExportEndFrame = cmds.getAttr("defaultRenderGlobals.endFrame")
cmdAlembicBase = 'AbcExport -j "'
cmdAlembicBase = cmdAlembicBase + '-frameRange '+str(ExportStartFrame)+' '+str(ExportEndFrame)
cmdAlembicBase = cmdAlembicBase + ' -uvWrite -attrPrefix xgen -worldSpace'
palette = cmds.ls( exactType="xgmPalette" )
for p in range( len(palette) ):
filename = abcFolderPath+ "/" + strSceneName + "__" + xgmExternalAPI.encodeNameSpace(str(palette[p])) + ".abc"
descShapes = cmds.listRelatives( palette[p], type="xgmDescription", ad=True )
cmdAlembic = cmdAlembicBase
for d in range( len(descShapes) ):
descriptions = cmds.listRelatives( descShapes[d], parent=True )
if len(descriptions):
patches = xg.descriptionPatches(descriptions[0])
for patch in patches:
cmd = 'xgmPatchInfo -p "'+patch+'" -g';
geom = mel.eval(cmd)
geomFullName = cmds.ls( geom, l=True )
cmdAlembic += " -root " + geomFullName[0]
cmdAlembic = cmdAlembic + ' -stripNamespaces -file \''+ filename+ '\'";';
print(cmdAlembic)
mel.eval(cmdAlembic)
def GetAbcFile(palette):
pExplode = palette.split(":")
pFirst = pExplode[0]
pSecond = pExplode[1]
for abcFile in abcFiles:
explode = abcFile.split("__ns__")
first = explode[0]
second = explode[1]
if pFirst in first and pSecond in second:
abcFilePath = abcFolderPath + "/" + abcFile
return str(os.path.normpath(abcFilePath))
return ""
def SetAttr():
if xgg.Maya:
#palette is collection, use palettes to get collections first.
palettes = xg.palettes()
for palette in palettes:
#print "Collection:" + palette
#Use descriptions to get description of each collection
descriptions = xg.descriptions(palette)
for description in descriptions:
#print " Description:" + description
objects = xg.objects(palette, description, True)
#Get active objects,e.g. SplinePrimtives
for object in objects:
#print " Object:" + object
attrs = xg.allAttrs(palette, description, object)
for attr in attrs:
#print " Attribute:" + attr + ", Value:" + xg.getAttr(attr, palette, description, object)
if attr == "custom__arnold_useAuxRenderPatch":
xg.setAttr("custom__arnold_useAuxRenderPatch",xge.prepForAttribute("True"),palette, description, object)
#xg.setActive(palette, description, "custom__arnold_useAuxRenderPatch", xge.prepForAttribute(True))
elif attr == "custom__arnold_auxRenderPatch":
print " Attribute:" + attr + ", Value:" + xg.getAttr(attr, palette, description, object)
abcFile = GetAbcFile(palette)
if abcFile != "":
#print(abcFile)
xg.setAttr(attr,xge.prepForAttribute(abcFile),palette, description, object)
#xg.setActive(palette, description, attr, xge.prepForAttribute(abcFile))
# de = xgg.DescriptionEditor
# de.refresh("Full")
xg.registerCallback("RenderAPIRendererTabUIInit", "xgenArnoldUI.xgArnoldUI")
xg.registerCallback("RenderAPIRendererTabUIRefresh", "xgenArnoldUI.xgArnoldRefresh")
if xg.xgGlobal.DescriptionEditor is not None:
xg.xgGlobal.DescriptionEditor.refresh("Full")
# generate abc
ExportBatchesAnim()
# custom__arnold_auxRenderPatch
SetAttr()
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme