Skip to content

Instantly share code, notes, and snippets.

Tai Komatsu taikomatsu

Block or report user

Report or block taikomatsu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
taikomatsu / fieldAttenuationApprox.txt
Last active Aug 29, 2015
Maya Field attenuation parameter approximation
View fieldAttenuationApprox.txt
// Maya Field attenuation parameter approximation
vector $p = particleShape1.position;
float $d = mag($p);
float $f = pow(1.0/($d+1.0), particleShape1.attenuation) * particleShape1.magnitude;
particleShape1.acceleration = <<0, $f, 0>>;
taikomatsu / gist:4bf29bf8dfcc45db409b
Created Jun 5, 2015
Open current working directory
View gist:4bf29bf8dfcc45db409b
from pymel.core import *
import os
import os.path
path, file = os.path.split(sceneName())
path = os.path.dirname(path).replace('/', '\\')
os.popen('explorer "%s"' % path)
# -- 5行目の注釈
# Windowsのコマンドプロンプトでexplorerを開く際はパスの区切りがスラッシュだとだめなのでバックスラッシュに直す。
# 通常であればos.path.normpath(os.path.dirname(path))で変更したいところだが、Mayaの場合Windowsでも/を返す為今回は自分で修正。
taikomatsu / gist:a57407ddbae0c48f1d4a
Created Jun 15, 2015
Make particles from selected mesh vertices
View gist:a57407ddbae0c48f1d4a
# make particles from selected mesh vertices
from pymel.core import *
vtxs = [PyNode(o) for o in filterExpand('%s.vtx[*]' % selected()[0].name(), sm=31)]
points = []
for o in vtxs:
particle(p=points, c=1)
print('# done')
View gist:99d34488eebe0225510f
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):
taikomatsu / gist:6fd0a4700098829acc19
Created Jun 24, 2015
Generate batch render commands
View gist:6fd0a4700098829acc19
# レンダリング用コマンドライン自動生成
# 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'
taikomatsu / gist:98f77bf067bb9bfd4ffd
Last active Aug 29, 2015
Render sequence on Render View
View gist:98f77bf067bb9bfd4ffd
# 何らかの理由で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
taikomatsu / gist:f599afaa1edf0dfc70af
Last active Aug 29, 2015
Copy a playbast movie file from tmp directory
View gist:f599afaa1edf0dfc70af
# 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
taikomatsu / gist:944e3a62ce638509f6fc
Created Jul 2, 2015
Get all (readable) attributes value and set it to another (only settable)
View gist:944e3a62ce638509f6fc
from pymel.core import *
# get all (readable) attributes value
o = selected()[0]
attrs = {}
for a in listAttr(o):
v = o.attr(a).get()
attrs[a] = v
except Exception, e:
print e
taikomatsu /
Created Jul 3, 2015
pymel vs OpenMaya speed test
# 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)
taikomatsu / gist:193b371c1670d2ca8264
Created Jul 4, 2015
Copy all textures in current scene
View gist:193b371c1670d2ca8264
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')
You can’t perform that action at this time.