def registerDefaultTranslator(nodeType, default): """ Register the default translator for a node type. The second argument identifies the name of the translator. Pass the translator name (as a string) if the default is always the same, or a function that takes the current node as a pymel PyNode and returns the translator name as a string. The default will automatically be set whenever a node of the given type is added to the scene. """ global _defaultTranslators _defaultTranslators[nodeType] = default isFunc = callable(default) if not isFunc: cmds.arnoldPlugins(setDefaultTranslator=(nodeType, default)) if arnoldIsCurrentRenderer(): it = pm.api.MItDependencyNodes() while not it.isDone(): obj = it.item() if not obj.isNull(): mfn = pm.api.MFnDependencyNode(obj) if mfn.typeName() == nodeType: plug = mfn.findPlug("aiTranslator") if not plug.isNull() and plug.asString() == "": if isFunc: val = default(obj) else: val = default plug.setString(val) it.next() callbacks.addNodeAddedCallback(_doSetDefaultTranslator, nodeType, applyToExisting=False, apiArgs=True)
def arnoldAboutDialog(): arnoldAboutText = u"Arnold for Maya\n\n" arnoldAboutText += "MtoA " + cmds.pluginInfo( 'mtoa', query=True, version=True) arnoldMercurialID = cmds.arnoldPlugins(getMercurialID=True) if not '(Master)' in arnoldMercurialID: arnoldAboutText += " - " + arnoldMercurialID arnoldAboutText += "\nArnold Core "+".".join(ai.AiGetVersion())+"\n\n" arnoldAboutText += u"(c) 2001-2009 Marcos Fajardo and (c) 2009-2015\nSolid Angle SL\n\n" arnoldAboutText += u"Developed by: Ángel Jimenez, Olivier Renouard,\nYannick Puech, Borja Morales, Nicolas Dumay,\nPedro Fernando Gomez, Pál Mezei\n\n" arnoldAboutText += u"Acknowledgements: Javier González, Miguel González, \nLee Griggs, Chad Dombrova, Gaetan Guidet, \nGaël Honorez, Diego Garcés, Kevin Tureski, \nFrédéric Servant" if (cmds.window("AboutArnold", ex=True)): cmds.deleteUI("AboutArnold") w = cmds.window("AboutArnold", title="About") cmds.window("AboutArnold", edit=True, width=402, height=280) cmds.rowColumnLayout( numberOfColumns=4, columnWidth=[(1,20), (2, 52), (3, 50), (4, 280)] ) cmds.text(label="");cmds.text(label="");cmds.text(label="");cmds.text(label="") cmds.text(label="") cmds.image(image="MtoA_Logo.png") cmds.text(label="") cmds.text(align="left",label=arnoldAboutText) cmds.text(label="");cmds.text(label="\n");cmds.text(label="");cmds.text(label="") cmds.text(label="") cmds.text(label="") cmds.button( width=150,label='OK', command=('import maya.cmds as cmds;cmds.deleteUI(\"' + w + '\", window=True)') ) cmds.setParent( '..' ) cmds.showWindow(w)
def createArnoldShelf(): mtoaMercurialID = cmds.arnoldPlugins(getMercurialID=True) try: if cmds.optionVar(exists='mtoaMercurialID'): mercurialID = cmds.optionVar(query='mtoaMercurialID') if mtoaMercurialID == mercurialID: return else: cmds.optionVar(sv=('mtoaMercurialID', mtoaMercurialID)) else: cmds.optionVar(sv=('mtoaMercurialID', mtoaMercurialID)) except: pass removeArnoldShelf() shelfTab = maya.mel.eval('global string $gShelfTopLevel;') maya.mel.eval('global string $arnoldShelf;') maya.mel.eval('$arnoldShelf = `shelfLayout -cellWidth 32 -cellHeight 32 -p $gShelfTopLevel Arnold`;') cmds.shelfButton(label='Flush Texture Cache', command='import maya.cmds as cmds; cmds.arnoldFlushCache(textures=True)', sourceType='python', annotation='Flush Texture Cache', image='FlushTextureShelf.png', style='iconOnly') cmds.shelfButton(label='Flush Background Cache', command='import maya.cmds as cmds; cmds.arnoldFlushCache(skydome=True)', sourceType='python', annotation='Flush Background Cache', image='FlushBackgroundShelf.png', style='iconOnly') cmds.shelfButton(label='Flush Quad Caches', command='import maya.cmds as cmds; cmds.arnoldFlushCache(quads=True)', sourceType='python', annotation='Flush Quad Caches', image='FlushQuadLightShelf.png', style='iconOnly') cmds.shelfButton(label='Flush All Caches', command='import maya.cmds as cmds;cmds.arnoldFlushCache(flushall=True)', sourceType='python', annotation='Flush All Caches', image='FlushAllCachesShelf.png', style='iconOnly') cmds.shelfButton(label='TX Manager', command='import mtoa.ui.arnoldmenu as arnoldmenu; arnoldmenu.arnoldTxManager()', sourceType='python', annotation='TX Manager', image='TXManagerShelf.png', style='iconOnly') cmds.shelfButton(label='Create Area Light', command='import mtoa.utils as mutils;mutils.createLocator("aiAreaLight", asLight=True)', sourceType='python', annotation='Create Area Light', image='AreaLightShelf.png', style='iconOnly') cmds.shelfButton(label='Create SkyDome Light', command='import mtoa.utils as mutils; mutils.createLocator("aiSkyDomeLight", asLight=True)', sourceType='python', annotation='Create SkyDome Light', image='SkydomeLightShelf.png', style='iconOnly') cmds.shelfButton(label='Create Physical Sky', command='import mtoa.cmds.arnoldShelf as arnoldShelf; arnoldShelf.createPhysicalSky()', sourceType='python', annotation='Create Physical Sky', image='PhysicalSkyShelf.png', style='iconOnly') cmds.shelfButton(label='Create Mesh Light', command='import mtoa.ui.arnoldmenu as arnoldmenu; arnoldmenu.doCreateMeshLight()', sourceType='python', annotation='Create Mesh Light', image='MeshLightShelf.png', style='iconOnly') cmds.shelfButton(label='Create Photometric Light', command='import mtoa.utils as mutils; mutils.createLocator("aiPhotometricLight", asLight=True)', sourceType='python', annotation='Create Photometric Light', image='PhotometricLightShelf.png', style='iconOnly')
def listTranslators(nodeType): ''' return a list of (translator, arnoldNode) pairs ''' import maya.cmds as cmds data = cmds.arnoldPlugins(listTranslators=nodeType) or [] # convert empty strings to None data = [x or None for x in data] return utils.groupn(data, 2)
def arnoldAboutDialog(): arnoldAboutText = u"Arnold for Maya\n\n" arnoldAboutText += "MtoA " + cmds.pluginInfo( 'mtoa', query=True, version=True) arnoldMercurialID = cmds.arnoldPlugins(getMercurialID=True) if not '(Master)' in arnoldMercurialID: arnoldAboutText += " - " + arnoldMercurialID arnoldAboutText += "\nArnold Core " + ".".join(ai.AiGetVersion()) + "\n\n" arnoldAboutText += u"(c) 2001-2009 Marcos Fajardo and (c) 2009-2015\nSolid Angle SL\n\n" arnoldAboutText += u"Developed by: Ángel Jimenez, Olivier Renouard,\nYannick Puech, Borja Morales, Nicolas Dumay,\nPedro Fernando Gomez, Pál Mezei\n\n" arnoldAboutText += u"Acknowledgements: Javier González, Miguel González, \nLee Griggs, Chad Dombrova, Gaetan Guidet, \nGaël Honorez, Diego Garcés, Kevin Tureski, \nFrédéric Servant" if (cmds.window("AboutArnold", ex=True)): cmds.deleteUI("AboutArnold") w = cmds.window("AboutArnold", title="About") cmds.window("AboutArnold", edit=True, width=402, height=280) cmds.rowColumnLayout(numberOfColumns=4, columnWidth=[(1, 20), (2, 52), (3, 50), (4, 280)]) cmds.text(label="") cmds.text(label="") cmds.text(label="") cmds.text(label="") cmds.text(label="") cmds.image(image="MtoA_Logo.png") cmds.text(label="") cmds.text(align="left", label=arnoldAboutText) cmds.text(label="") cmds.text(label="\n") cmds.text(label="") cmds.text(label="") cmds.text(label="") cmds.text(label="") cmds.button(width=150, label='OK', command=('import maya.cmds as cmds;cmds.deleteUI(\"' + w + '\", window=True)')) cmds.setParent('..') cmds.showWindow(w)
def getAttributeData(nodeType): import maya.cmds as cmds data = cmds.arnoldPlugins(getAttrData=nodeType) or [] # convert empty strings to None data = [x or None for x in data] return utils.groupn(data, 4)