hajimen @ ウィキ
http://w.atwiki.jp/hajimen/
hajimen @ ウィキ
ja
2011-02-09T12:49:13+09:00
1297223353
-
get mDagPath from Name
https://w.atwiki.jp/hajimen/pages/130.html
#highlight(python){{
def mDagPathFromName(name):
selList = OpenMaya.MSelectionList()
selList.add(name)
mDagPath = OpenMaya.MDagPath()
selList.getDagPath(0, mDagPath)
return mDagPath
}}
2011-02-09T12:49:13+09:00
1297223353
-
Maya Python逆引き
https://w.atwiki.jp/hajimen/pages/123.html
-[[get mDagPath from Name]]
-[[get screen position]]
-[[get openGL screen size]]
-[[define new function on time]]
-[[Select All Objects in the camera view]]
2011-02-09T12:48:58+09:00
1297223338
-
get screen position
https://w.atwiki.jp/hajimen/pages/129.html
Use M3dView.
#highlight(python){{
def screenPositionAPI(panel, pos):
mp = OpenMaya.MPoint(pos[0], pos[1], pos[2])
m3v = OpenMayaUI.M3dView.active3dView()
OpenMayaUI.M3dView.getM3dViewFromModelPanel(panel, m3v)
xp = OpenMaya.MScriptUtil().asShortPtr()
yp = OpenMaya.MScriptUtil().asShortPtr()
ret = m3v.worldToView(mp, xp, yp)
x = OpenMaya.MScriptUtil().getShort(xp)
y = OpenMaya.MScriptUtil().getShort(yp)
xPtr = OpenMaya.MScriptUtil().asUintPtr()
yPtr = OpenMaya.MScriptUtil().asUintPtr()
widthPtr = OpenMaya.MScriptUtil().asUintPtr()
heightPtr = OpenMaya.MScriptUtil().asUintPtr()
m3v.viewport(xPtr, yPtr, widthPtr, heightPtr)
viewWidth = OpenMaya.MScriptUtil().getUint( widthPtr )
viewHeight = OpenMaya.MScriptUtil().getUint( heightPtr )
return (float(x)/float(viewWidth), float(y)/float(viewHeight))
}}
Or calculate by yourself(using inverse Matrix)
#highlight(python){{
def screenPositionAPI2(cam, pos):
mp = OpenMaya.MPoint(pos[0], pos[1], pos[2])
camDagPath = mDagPathFromName(cam)
mtx = camDagPath.inclusiveMatrixInverse()
newPos = mp * mtx
resX = - newPos.x / newPos.z * cmds.camera(cam, q=True, fl=True)
resY = - newPos.y / newPos.z * cmds.camera(cam, q=True, fl=True)
resX /= cmds.camera(cam, q=True, hfa=True)/ 25.4
resY /= cmds.camera(cam, q=True, vfa=True)/ 25.4
return (resX, resY)
}}
This one is better.
#highlight(python){{
import math
def screenPositionAPI3(cam, pos):
mp = OpenMaya.MPoint(pos[0], pos[1], pos[2])
camDagPath = mDagPathFromName(cam)
mtx = camDagPath.inclusiveMatrixInverse()
newPos = mp * mtx
hfv = cmds.camera(cam, q=True, hfv=True)
resX = ((newPos.x/(-newPos.z))/math.tan(math.radians(hfv/2)))/2.0;
vfv = cmds.camera(cam, q=True, vfv=True)
resY = ((newPos.y/(-newPos.z))/math.tan(math.radians(vfv/2)))/2.0;
return (resX, resY)
}}
2011-02-09T12:44:19+09:00
1297223059
-
get openGL screen size
https://w.atwiki.jp/hajimen/pages/128.html
#highlight(python){{
def getScreenRes(panel):
m3v = OpenMayaUI.M3dView.active3dView()
OpenMayaUI.M3dView.getM3dViewFromModelPanel(panel, m3v)
xPtr = OpenMaya.MScriptUtil().asUintPtr()
yPtr = OpenMaya.MScriptUtil().asUintPtr()
widthPtr = OpenMaya.MScriptUtil().asUintPtr()
heightPtr = OpenMaya.MScriptUtil().asUintPtr()
m3v.viewport(xPtr, yPtr, widthPtr, heightPtr)
viewWidth = OpenMaya.MScriptUtil().getUint( widthPtr )
viewHeight = OpenMaya.MScriptUtil().getUint( heightPtr )
return (float(viewWidth), float(viewHeight))
}}
2011-02-09T12:35:01+09:00
1297222501
-
define new function on time
https://w.atwiki.jp/hajimen/pages/127.html
This example shows the way to define python function and use it from Maya Expression. Note it only works during Maya session.
#highlight(python){{
def timeChangeScript():
print "new Frame!"
import __main__
__main__.hogehoge = timeChangedScript
cmd = 'python("hogehoge()");'
cmds.expression(
s=cmd,
ae=1,
uc='all',
name='timeChangedScript',
)
}}
2011-02-07T10:18:41+09:00
1297041521
-
Connect to Maya
https://w.atwiki.jp/hajimen/pages/126.html
Use this lisp.
http://koichitamura.blogspot.com/2009/06/emacs-to-maya-for-python-scripts.html
You have to run below commands from Maya before use.
#highlight(c){{
commandPort -eo -n "127.0.0.1:2222";// Only Vista & Windows7
commandPort -eo -n ":2222"; }}
http://area.autodesk.com/forum/autodesk-maya/python/commandport-doesnt-work-in-vista-32
2011-01-16T15:15:02+09:00
1295158502
-
Emacs逆引き
https://w.atwiki.jp/hajimen/pages/18.html
-[[Pythonでtabをスペース4つ分の幅に]]
-[[キーバインド一覧]]
-[[EmacsでOSX用に文字コード、改行コードを変える]]
-[[spaceをTABに]]
-[[Connect to Maya]]
2011-01-16T15:12:04+09:00
1295158324
-
Windows7
https://w.atwiki.jp/hajimen/pages/125.html
インストール時やる事
ワコムのタブレットが異様にひっかかります。
http://d.hatena.ne.jp/takhino/20091103/1257226350
波紋のせいかと思ったら、「プレス アンド ホールド機能」が原因らしい。
新タスクバーにはbatは登録できません。
http://nonsubject.blogspot.com/2010/01/windows-7.html
なのでクイック起動を使います。
http://pasofaq.jp/windows/windows7/rc-quicklaunch.htm
SendToの場所も変更されました。
http://starfort.cocolog-nifty.com/voorlihter/2009/12/windows-7-send-.html
2011-01-15T20:27:28+09:00
1295090848
-
メニュー
https://w.atwiki.jp/hajimen/pages/2.html
**Menu
-[[トップページ]]
-[[Maya]]
-[[Maya MEL逆引き]]
-[[Maya Python逆引き]]
-[[Mayaman Air]]
-[[Python逆引き]]
-[[GAE/Django逆引き]]
-[[windows逆引き]]
-[[OSX逆引き]]
-[[linux逆引き]]
-[[Emacs逆引き]]
-[[MySQL逆引き]]
-[[djv逆引き]]
-[[Shake逆引き]]
-[[Windows7]]
//**更新履歴
//#recent(20)
&link_editmenu(text=ここを編集)
2011-01-15T20:10:46+09:00
1295089846
-
Select All Objects in the camera view
https://w.atwiki.jp/hajimen/pages/124.html
#highlight(python){{
import maya.OpenMaya as OpenMaya
import maya.OpenMayaUI as OpenMayaUI
def selectAllVisibleObjectsFromScreen():
activePane=OpenMayaUI.M3dView.active3dView()
w=activePane.portWidth()
h=activePane.portHeight()
myX=OpenMaya.MScriptUtil()
myX.createFromInt(0)
myY=OpenMaya.MScriptUtil()
myY.createFromInt(0)
myEndX=OpenMaya.MScriptUtil()
myEndX.createFromInt(w)
myEndY=OpenMaya.MScriptUtil()
myEndY.createFromInt(h)
OpenMaya.MGlobal.selectFromScreen(
myX.asShortPtr(),
myY.asShortPtr(),
myEndX.asShortPtr(),
myEndY.asShortPtr(),
OpenMaya.MGlobal.kReplaceList
)
}}
2011-01-15T08:36:06+09:00
1295048166