代码段记录 跟踪报错位置 转载于vanny yuan’s
1 2 3 4 5 6 7 try: import 模块 reload(模块) 模块.func() except: import traceback traceback.print_exc()
Maya的runTimeCommand所在路径 转载于vanny yuan’s
1 2 3 4 5 6 7 8 9 10 11 12 13 14 // 直接运行 attachCache // 查询attachCache类型 whatIs attachCache // Result: Run Time Command // // 查询runTimeCommand调用的方法 runTimeCommand -q -command attachCache // Result: doAttachCacheArgList(0,{}) // // 查询doAttachCacheArgList whatIs doAttachCacheArgList // Result: Mel procedure found in: C:/Program Files/Autodesk/Maya2018/scripts/others/doAttachCacheArgList.mel //
maya的环境变量 官方网站 中文翻译 转载凌云
常用
1 2 3 4 MAYA_DISABLE_CLIC_IPM=1 关闭登录功能 MAYA_UI_LANGUAGE zh_CN或en_US 切换语言
切换到总渲染层 python
1 2 cmds.editRenderLayerGlobals( currentRenderLayer='defaultRenderLayer' ) cmds.setAttr('defaultRenderLayer.renderable',0)
进入摄像机视角 python
1 cmds.lookThru('camera1')
获取渲染层id mel
1 listConnections renderLayerManager.renderLayerId
当前渲染器 mel
ui面板id python
1 panes=cmds.getPanel( type='modelPanel')
关闭缩略图 python
1 cmds.renderThumbnailUpdate(False)
鼠标状态 python
1 2 cmds.waitCursor( state=True ) cmds.waitCursor( state=False )
返回当前活动窗口 1 cmds.getPanel(withFocus=True)
判断两个模型是否可以做blendshape 1 2 3 sel = cmds.ls(sl=1) print(sel) ret = cmds.polyCompare(sel,v=1,e=1,fd=1)
拍屏代码参考 1 2 3 cmds.playblast(forceOverwrite=True, clearCache=True, startTime=1, endTime=10, sequenceTime=0, percent=100, quality=100, framePadding=4, widthHeight=[960, 540], format='qt', compression="MPEG-4 Video", showOrnaments=True, viewer=False, offScreen=True, filename='D:/cs.mov')
撤销多步 一个功能包含多个command命令,想要一次撤回所有command,需要包裹代码块
1 2 3 cmds.undoInfo(openChunk=True) 代码 cmds.undoInfo(closeChunk=True)
dock 停靠窗口 上连接
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 from maya.app.general.mayaMixin import MayaQWidgetDockableMixin from PySide2 import QtWidgets class MyDockableWindow(MayaQWidgetDockableMixin, QtWidgets.QWidget): def __init__(self): super(MyDockableWindow, self).__init__() # Delete existing UI try: cmds.deleteUI('MDWWorkspaceControl') except RuntimeError: pass self.setWindowTitle('My Dockable Window') self.resize(500, 400) self.setObjectName('MDW') self.show(dockable=True) MyWin = MyDockableWindow()
mesh坐标轴跟组保持一致? 1 2 3 a = cmds.makeIdentity('pCube1', a=1, t=1, r=1, s=1, n=0, pn=1) a = cmds.makeIdentity('pCube1', a=0, t=1, r=1, s=1)
判断mesh是否重命名 1 2 3 4 try: mesh = cmds.listRelatives(mesh的shape节点, parent=True)[0] expcept: print "有重命名mesh"