This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
# Playblastをした後にその動画が保存したくなった場合にblast_nameに動画の名前(名前のみでOK)を入力すると | |
# TMPから勝手に引っ張ってきてcurrent_project/moviesにコピーします | |
# ムービーの名前はPlayblastが終わった直後、パスが表示されるのでそれを見て手動で入力してください | |
# UIあるととても便利でしたね(放置中) | |
# copy blast from tmp | |
from pymel.core import * | |
import os | |
import os.path | |
import shutil |
This file contains hidden or 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_nodesを複数にするとフレームを分割してコマンドをprintする | |
# フレームの分割がたまにミスるのはご愛嬌(放置中) | |
from pymel.core import * | |
# settings | |
tmpl = '"%(render_path)s" -r %(renderer)s %(frame_range)s -proj "%(proj)s" "%(scene)s"' | |
render_path = r'C:\Program Files\Autodesk\Maya2014\bin\Render' | |
renderer = 'mr' | |
platform = 'win' |
This file contains hidden or 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
# 何らかの理由でbatchレンダリングがうまくいかない、Maya HWだと何故かレンダリングが遅い、みたいなときに便利なスクリプト | |
# 連番をRender View上でレンダリングします | |
# Progress window付きでキャンセルすることが可能ですが、なぜかRender Viewの下に隠れてしまうので上手いことやらないとキャンセル出来ないので要注意 | |
from pymel.core import * | |
from maya import mel | |
import math | |
preroll_start = None | |
s = int(playbackOptions(q=True, min=True)) # start frame | |
e = int(playbackOptions(q=True, max=True)) # end frame |
This file contains hidden or 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 maya import OpenMaya | |
from pymel.core import * | |
import math | |
class UvCoord(object): | |
def __init__(self, u, v): | |
self.u = u | |
self.v = v | |
def dist(self, uv): |