本文整理汇总了Python中maya.cmds.inViewMessage方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.inViewMessage方法的具体用法?Python cmds.inViewMessage怎么用?Python cmds.inViewMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.inViewMessage方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: maya_import
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import inViewMessage [as 别名]
def maya_import():
temp = __name__.split('.')#nameは自分自身のモジュール名。splitでピリオドごとに3分割。
folderPath = os.path.join(os.getenv('MAYA_APP_DIR'),'Scripting_Files','go')
if not os.path.exists(folderPath):
os.makedirs(os.path.dirname(folderPath+'\\')) # 末尾\\が必要なので注意
#print folderPath
files = os.listdir(folderPath)
if files is not None:
for file in files:
print file
nameSpace = file.replace('.ma', '')
cmds.file(folderPath+'\\'+file, i=True, typ="mayaAscii", iv=True, mnc=False, options="v=0;", pr=True)
#重複マテリアルにファイル名が頭に付与されてしまうのを修正
allMat = cmds.ls(mat=True)
fileName = file.split('.')[0]
for mat in allMat:
if mat.startswith(fileName+'_'):
cmds.rename(mat, mat.replace(fileName+'_', ''))
cmds.inViewMessage( amg='<hl>Go Maya</hl> : Imoprt objects', pos='midCenterTop', fade=True, ta=0.75, a=0.5)
else:
cmds.inViewMessage( amg='<hl>Go Maya</hl> : There is no exported object', pos='midCenterTop', fade=True, ta=0.75, a=0.5)
示例2: maya_import
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import inViewMessage [as 别名]
def maya_import():
temp = __name__.split('.')#nameは自分自身のモジュール名。splitでピリオドごとに3分割。
folderPath = os.path.join(os.getenv('MAYA_APP_DIR'),'Scripting_Files','go')
if not os.path.exists(folderPath):
os.makedirs(os.path.dirname(folderPath+os.sep)) # 末尾\\が必要なので注意
#print folderPath
files = os.listdir(folderPath)
if files is not None:
for file in files:
print file
nameSpace = file.replace('.ma', '')
cmds.file(folderPath+os.sep+file, i=True, typ="mayaAscii", iv=True, mnc=False, options="v=0;", pr=True)
#重複マテリアルにファイル名が頭に付与されてしまうのを修正
allMat = cmds.ls(mat=True)
fileName = file.split('.')[0]
for mat in allMat:
if mat.startswith(fileName+'_'):
cmds.rename(mat, mat.replace(fileName+'_', ''))
cmds.inViewMessage( amg='<hl>Go Maya</hl> : Imoprt objects', pos='midCenterTop', fade=True, ta=0.75, a=0.5)
else:
cmds.inViewMessage( amg='<hl>Go Maya</hl> : There is no exported object', pos='midCenterTop', fade=True, ta=0.75, a=0.5)
示例3: match_transform
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import inViewMessage [as 别名]
def match_transform(mode='', child_comp=False):
from . import sisidebar_sub
pre_sel = cmds.ls(sl=True, l=True)
selection = cmds.ls(sl=True, l=True, type='transform')
if not selection:
return
cmds.undoInfo(openChunk=True)
set_maching(nodes=selection, mode=mode ,pre_sel=pre_sel, child_comp=child_comp)
msg = lang.Lang(en=u"<hl>Select Matching Object</hl>",
ja=u"<hl>一致対象オブジェクトを選択してください</hl>")
cmds.inViewMessage( amg=msg.output(), pos='midCenterTop', fade=True )
#cmds.select(cl=True)
maching_tool = cmds.scriptCtx( title='Much Transform',
totalSelectionSets=3,
cumulativeLists=True,
expandSelectionList=True,
toolCursorType="edit",
setNoSelectionPrompt='Select the object you want to matching transform.'
)
#カスタムカーソルを設定
image_path = os.path.join(os.path.dirname(__file__), 'icon/')
my_cursor = QCursor(QPixmap(image_path+'picker.png'))
QApplication.setOverrideCursor(my_cursor)
#cmds.hudButton('HUDHelloButton', e=True, s=7, b=5, vis=1, l='Button', bw=80, bsh='roundRectangle', rc=match_cancel )
global hud_but
if maya_ver != 2017:
try:
hud_but = cmds.hudButton('HUD_match_cancel', s=7, b=5, vis=1, l='Cancel', bw=80, bsh='roundRectangle', rc=finish_matching)
#print 'create'
except:
#print 'change'
hud_but = cmds.hudButton('HUD_match_cancel',e=True, s=7, b=5, vis=1, l='Cancel', bw=80, bsh='roundRectangle', rc=finish_matching)
jobNum = cmds.scriptJob(ro=True, e=('SelectionChanged', qt.Callback(trs_matching)), protected=True)
sisidebar_sub.get_matrix()
示例4: maya_export
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import inViewMessage [as 别名]
def maya_export():
selection = cmds.ls(sl=True)
long_names = cmds.ls(sl=True, l=True)
if selection:
cmds.inViewMessage( amg='<hl>Go Maya</hl> : Export Selected Objects', pos='midCenterTop', fade=True, ta=0.75, a=0.5)
temp = __name__.split('.')#nameは自分自身のモジュール名。splitでピリオドごとに3分割。
folderPath = os.path.join(
os.getenv('MAYA_APP_DIR'),#Mayaのディレクトリ環境変数を取得
'Scripting_Files',
temp[-1]
)
if not os.path.exists(folderPath):
os.makedirs(os.path.dirname(folderPath+'\\')) # 末尾\\が必要なので注意
print folderPath
files = os.listdir(folderPath)
sel_dict = dict()
if files is not None:
for file in files:
os.remove(folderPath + '\\' + file)
for sel, long_name in zip(selection, long_names):
cmds.select(sel, r=True)
name = sel.replace('|', '__Pipe__')
cmds.file(folderPath+'\\'+name+'.ma', force=True, options="v=0", typ="mayaAscii", pr=True, es=True)
sel_dict[name+'.ma'] = long_name
cmds.select(selection, r=True)
#選択ノード名を保存
fine_name = folderPath+'\\go_maya_selection_node.json'
with open(fine_name, 'w') as f:
json.dump(sel_dict, f)
示例5: set_work_space
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import inViewMessage [as 别名]
def set_work_space(root_dir):
cmds.workspace(root_dir, o=True)
current_project = cmds.workspace(q=True, rootDirectory=True)
print 'Set Current Work Space :', current_project
msg00 = lang.Lang(
en='Set Current Work Space :<hl>'+current_project+'<hl>',
ja=u'現在のプロジェクトを<hl>' +current_project+u'</hl>に設定しました')
cmds.inViewMessage( amg=msg00.output(), pos='midCenterTop', fade=True, ta=0.75, a=0.5)
#ドラッグドロップでオープンシーンする
示例6: viewMassage
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import inViewMessage [as 别名]
def viewMassage(text = None):
cmds.inViewMessage( amg="Pipeline: " + text, pos='topCenter', fade=True, fst = 3000 )
示例7: initializeCallback
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import inViewMessage [as 别名]
def initializeCallback(self):
#get current model panel
self.currentModelPanel = cmds.getPanel(wf = 1)
if "modelPanel" not in self.currentModelPanel:
self.currentModelPanel = cmds.getPanel(vis = 1)
for i in self.currentModelPanel:
if "modelPanel" in i:
self.currentModelPanel = i
#try removing old callbacks from memory
try:
OpenMayaUI.MUiMessage.removeCallback(self.callBack)
except:
pass
#create a callback that is registered after a frame is drawn with a 3D content but before 2D content
self.callback = OpenMayaUI.MUiMessage.add3dViewPostRenderMsgCallback(self.currentModelPanel, self.update)
self.view3D.refresh(True, True)
#create QT maya window event filter
main_window_ptr = OpenMayaUI.MQtUtil.mainWindow()
self.qt_Maya_Window = wrapInstance(long(main_window_ptr), QtCore.QObject)
self.qt_Maya_Window.installEventFilter(self.userKeyboardEvents)
#create viewport event filter
active_view_ptr = self.view3D.widget()
self.qt_Active_View = wrapInstance(long(active_view_ptr), QtCore.QObject)
self.qt_Active_View.installEventFilter(self.userMouseEvents)
cmds.inViewMessage( amg='<hl>Tool:</hl> Use <hl>"Esc"</hl> to cancel the tool', pos='botLeft', fade=True )
print "Initialized..."
示例8: editPivotHandle
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import inViewMessage [as 别名]
def editPivotHandle(self):
qt_maya_window.installEventFilter(self.keypressFilter)
#create transform
self.pivotHandle = mc.group(em=True, name='Adjust_Pivot')
mc.setAttr(self.pivotHandle+'.rotate', lock=True)
mc.setAttr(self.pivotHandle+'.rx', keyable=False)
mc.setAttr(self.pivotHandle+'.ry', keyable=False)
mc.setAttr(self.pivotHandle+'.rz', keyable=False)
mc.setAttr(self.pivotHandle+'.scale', lock=True)
mc.setAttr(self.pivotHandle+'.sx', keyable=False)
mc.setAttr(self.pivotHandle+'.sy', keyable=False)
mc.setAttr(self.pivotHandle+'.sz', keyable=False)
mc.setAttr(self.pivotHandle+'.visibility', lock=True, keyable=False)
mc.setAttr(self.pivotHandle+'.displayHandle', True)
self.pivotHandle = mc.parent(self.pivotHandle, self.node)[0]
mc.addAttr(self.pivotHandle, ln='ml_pivot_handle', at='bool', keyable=False)
#set initial position
mc.setAttr(self.pivotHandle+'.translate', *mc.getAttr(self.node+'.rotatePivot')[0])
#lock it so you don't delete it or something.
mc.lockNode(self.pivotHandle, lock=True)
self.scriptJob = mc.scriptJob(event=['SelectionChanged', self.cleanup], runOnce=True)
mc.setToolTo('Move')
mc.inViewMessage( amg='After moving the pivot, press <hl>Return</hl> to bake or <hl>Esc</hl> to cancel.', pos='midCenterTop', fade=True, fadeStayTime=4000, dragKill=True)
示例9: message
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import inViewMessage [as 别名]
def message(msg, position='midCenterTop'):
OpenMaya.MGlobal.displayWarning(msg)
fadeTime = min(len(message)*100, 2000)
mc.inViewMessage( amg=msg, pos=position, fade=True, fadeStayTime=fadeTime, dragKill=True)
示例10: maya_export
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import inViewMessage [as 别名]
def maya_export():
selection = cmds.ls(sl=True)
long_names = cmds.ls(sl=True, l=True)
if selection:
cmds.inViewMessage( amg='<hl>Go Maya</hl> : Export Selected Objects', pos='midCenterTop', fade=True, ta=0.75, a=0.5)
temp = __name__.split('.')#nameは自分自身のモジュール名。splitでピリオドごとに3分割。
folderPath = os.path.join(
os.getenv('MAYA_APP_DIR'),#Mayaのディレクトリ環境変数を取得
'Scripting_Files',
temp[-1]
)
if not os.path.exists(folderPath):
os.makedirs(os.path.dirname(folderPath+os.sep)) # 末尾\\が必要なので注意
print folderPath
files = os.listdir(folderPath)
sel_dict = dict()
if files is not None:
for file in files:
os.remove(folderPath + os.sep + file)
for sel, long_name in zip(selection, long_names):
cmds.select(sel, r=True)
name = sel.replace('|', '__Pipe__')
cmds.file(folderPath+os.sep+name+'.ma', force=True, options="v=0", typ="mayaAscii", pr=True, es=True)
sel_dict[name+'.ma'] = long_name
cmds.select(selection, r=True)
#選択ノード名を保存
fine_name = folderPath+os.sep +'go_maya_selection_node.json'
with open(fine_name, 'w') as f:
json.dump(sel_dict, f)
示例11: freeze_transform
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import inViewMessage [as 别名]
def freeze_transform(mode='', c_comp=False):
from . import sisidebar_sub
selections = cmds.ls(sl=True, l=True, tr=True)
#下からのマルチ選択でも正しく上からフリーズできるように階層深さでソート
sel_depth = [[sel, check_depth(sel)] for sel in selections]
sel_depth = sorted(sel_depth, key=lambda a:a[1])
for sel in sel_depth:
sel = sel[0]
dummy = common.TemporaryReparent().main(mode='create')
srt_dummy = common.TemporaryReparent().main(mode='create')
#common.TemporaryReparent().main(sel, dummyParent=dummy, mode='cut')
if not c_comp:
set_maching(nodes=srt_dummy, mode='all', pre_sel=selections)
matching_obj=srt_dummy
trs_matching(node=sel, sel_org=False)
common.TemporaryReparent().main(sel,dummyParent=dummy, srtDummyParent=srt_dummy, mode='custom_cut', preSelection=selections)
attr_lock_flag_list = check_attr_locked(sel)
try:
if mode == 'all':
cmds.makeIdentity(sel, n=0, s=1, r=1, jointOrient=1, t=1, apply=True, pn=1)
cmds.xform(srt_dummy, t=[0, 0, 0])
cmds.xform(srt_dummy, ro=[0, 0, 0])
cmds.xform(srt_dummy, s=[1, 1, 1])
if mode == 'trans':
cmds.makeIdentity(sel, n=0, s=0, r=0, jointOrient=0, t=1, apply=True, pn=1)
cmds.xform(srt_dummy, t=[0, 0, 0])
if mode == 'rot':
cmds.makeIdentity(sel, n=0, s=0, r=1, jointOrient=0, t=0, apply=True, pn=1)
cmds.xform(srt_dummy, ro=[0, 0, 0])
if mode == 'scale':
cmds.makeIdentity(sel, n=0, s=1, r=0, jointOrient=0, t=0, apply=True, pn=1)
cmds.xform(srt_dummy, s=[1, 1, 1])
if mode == 'joint':
if cmds.nodeType(sel) == 'joint':
cmds.makeIdentity(sel, n=0, s=0, r=0, jointOrient=1, t=0, apply=True, pn=1)
cmds.xform(srt_dummy, ro=[0, 0, 0])
if mode == 'trans' or mode =='all':
cmds.xform(sel+'.scalePivot', t=[0, 0, 0], os=True)
cmds.xform(sel+'.rotatePivot', t=[0, 0, 0], os=True)
except Exception as e:
print e.message
cmds.inViewMessage( amg=e.message, pos='midCenterTop', fade=True, ta=0.75, a=0.5)
set_attr_locked(sel, attr_lock_flag_list)
common.TemporaryReparent().main(sel, dummyParent=dummy, mode='parent')
common.TemporaryReparent().main(sel, dummyParent=srt_dummy, mode='parent')
common.TemporaryReparent().main(dummyParent=dummy, mode='delete')#
common.TemporaryReparent().main(dummyParent=srt_dummy, mode='delete')#ダミー親削除
cmds.select(selections, r=True)
sisidebar_sub.get_matrix()
示例12: main
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import inViewMessage [as 别名]
def main(self, skinMeshes, mode='copy', saveName='default', method='index', weightFile='auto',
threshold=0.2, engine='maya', tgt=1, path='default', viewmsg=False):
if viewmsg:
cmds.inViewMessage( amg='<hl>Simple Weight</hl> : '+mode, pos='midCenterTop', fade=True, ta=0.75, a=0.5)
'''
ウェイトデータの保存、読み込み関数
mode→コピーするかペーストするか'copy'or'paste'
saveName→ウェイトデータの保存フォルダ名。ツール、モデル名とかで分けたい場合に指定
method→ペーストの仕方,「index」、「nearest」、「barycentric」、「over」
「index」法は、頂点インデックスを使用してウェイトをオブジェクトにマッピングします。マッピング先のオブジェクトと書き出し後のデータのトポロジが同じ場合、これが最も便利な手法です。
「nearest」法は、読み込んだデータのニアレスト頂点を検索し、ウェイト値をその値に設定します。これは、高解像度メッシュを低解像度メッシュにマッピングする場合に最適です。
「barycentric」法はポリゴン メッシュでのみサポートされます。ターゲット ジオメトリのニアレスト三角を検索し、
ソース ポイントと頂点の距離に応じてウェイトを再スケールします。これは通常、高解像度メッシュにマッピングされる粗いメッシュで使用されます。
「over」法は「index」法に似ていますが、マッピング前に対象メッシュのウェイトがクリアされないため、一致していないインデックスのウェイトがそのまま維持されます。
nearest と barycentricは不具合のため現状仕様不可能(処理が終わらない)2016/11/03現在
→barycentric、bylinearはMaya2016Extention2から利用可能
weightFile→メッシュ名検索でなく手動指定したい場合にパスを指定。methodのnearest、barycentricとセットで使う感じ。
→Mayaコピー時にファイル名指定すると複数保存できないので注意。
threshold→nearest,barycentricの位置検索範囲
'''
self.skinMeshes = skinMeshes
self.saveName = saveName
self.method = method
self.weightFile = weightFile
self.threshold = threshold
self.engine = engine
self.memShapes = {}
self.target = tgt
self.pasteMode = {'index':1, 'nearest':3}
# リストタイプじゃなかったらリストに変換する
if not isinstance(self.skinMeshes, list):
temp = self.skinMeshes
self.skinMeshes = []
self.skinMeshes.append(temp)
# ファイルパスを生成しておく
if path == 'default':
self.filePath = os.getenv('MAYA_APP_DIR') + os.sep +'Scripting_Files'+ os.sep + 'weight' + os.sep + self.saveName
elif path == 'project':
self.scene_path = os.sep.join(cmds.file(q=True, sceneName=True).split(os.sep)[:-1])
self.protect_path = os.path.join(self.scene_path, 'weight_protector')
try:
if not os.path.exists(self.protect_path):
os.makedirs(self.protect_path)
except Exception as e:
print e.message
return
self.filePath = self.protect_pat+os.sep + self.saveName
self.fileName = os.path.join(self.filePath, self.saveName + '.json')
self.apiName = os.path.join(self.filePath, self.saveName + '.skn')
# コピーかペーストをそれぞれ呼び出し
if mode == 'copy':
self.weightCopy()
if mode == 'paste':
self.weightPaste()