This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymel.core import * | |
# get all (readable) attributes value | |
o = selected()[0] | |
attrs = {} | |
for a in listAttr(o): | |
try: | |
v = o.attr(a).get() | |
attrs[a] = v | |
except Exception, e: | |
print e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this test executed on 80,000 vertices sphere and 6 faces box | |
from pymel.core import * | |
from time import time | |
from maya import OpenMaya | |
def calc_time(f): | |
def fn(*args, **kwargs): | |
s = time() | |
r = f(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymel.core import * | |
import shutil | |
copydir = r'z:\path\to\copy' | |
for o in ls(type='file'): | |
path = o.fileTextureName.get() | |
shutil.copy(path, copydir) | |
print('# Done') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymel.core import * | |
# 確実にエッジを取得したいのでfilterExpandを使用。 | |
e = filterExpand(sm=32)[0] | |
# 更にfilterExpandを使用するとls -flをした時と同様に要素が1つずつ確実に返ってくる。 | |
# edgeの両端のvertexの場合、頂点番号がつながっているとそのまま1まとまりで返されたりする。 | |
# なので念のため再度filterExpandに渡してデータにエラーがないようにしている。 | |
# filterExpandでは文字列を返してくるため最後にPyNodeを使ってpymelオブジェクトに変換。 | |
v = [PyNode(v) for v in filterExpand(polyListComponentConversion(e, fromEdge=True, toVertex=True), sm=31)] | |
space = 'world' | |
# normal()はnormalizeされたデータのコピーを返す。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ReadのfileでTcl書式のExpressionが使われていた場合に | |
# パスを展開して取り出す方法 | |
import nuke | |
reads = [o for o in nuke.selectedNodes() if o.Class() == 'Read'] | |
for o in reads: | |
filepath = o.knob('file').getValue() | |
print nuke.tcl('subst', filepath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ReadのfileでTcl書式のExpressionが使われていた場合に | |
# パスを展開して取り出す方法 改良版 | |
# ※この方法だと%04dとかも一緒に展開される模様 | |
import nuke | |
for o in nuke.selectedNodes('Read'): | |
filepath = o['file'].evaluate() | |
print(filepath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mayaで大量のシーンのplayblastを一斉に取りたい時用のスクリプト。 | |
# 事前に取得したシーンファイル名をムービー保存ディレクトリと一緒に渡すとプレイブラスト開始。 | |
# このスクリプトではフォーカスしたいオブジェクトを記述すればそれにフォーカスしてプレイブラストをするものの、 | |
# カメラの固定やジョイントの表示をOFFにしたいなどあれこれやりたいことはあると思うので、 | |
# その場合はviewport settingsの下辺りに追加してやればOKのはず。 | |
from pymel.core import * | |
import os | |
import os.path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Alembicを全体で1ファイルではなく各フレームごとに出力したい場合に使用 | |
# 以下では1-100Fまでを出力 | |
# start, endの値を書き換えてデータを出力しているので、ファイル名に$Fなどが入っていないとだめ | |
abc = hou.node('/obj/obj_name/rop_alembic1') | |
for i in range(100): | |
f = i + 1 | |
abc.parm('f1').set(f) | |
abc.parm('f2').set(f) | |
abc.parm('execute').pressButton() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root = hou.node('/') | |
rop = hou.node('/out/any_rop') | |
root.recursiveGlob(rop.evalParm('forceobject'), hou.nodeTypeFilter.Obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# render用のdelayed loadオブジェクトとシェーダを作成する | |
# 当然それらにはリンクが設定してある状態になる | |
# SOPで任意のノード(rop_alembic, rop_geometry, filecache)を選んでshelfボタンをポチで完了 | |
import hou | |
type_pairs = {'rop_alembic': 'filename', | |
'rop_geometry': 'sopoutput', | |
'filecache': 'file'} |