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
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
taikomatsu / gat_MDagPath_from_object_name.py
Last active Jan 10, 2017
Get MDagPath from object name
View gat_MDagPath_from_object_name.py
from maya import OpenMaya
import pymel.core as pm
def mdagpath_from_name(name):
if not pm.objExists(name):
raise MayaNodeError, name
slist = OpenMaya.MSelectionList()
slist.add(name)
dagpath = OpenMaya.MDagPath()
slist.getDagPath(0, dagpath)
@taikomatsu
taikomatsu / stick_points_to_mesh.py
Last active Jan 10, 2017
Stick points to closest point on a specified mesh
View stick_points_to_mesh.py
from maya import OpenMaya
import pymel.core as pm
def mdagpath_from_name(name, extend_to_shape=False):
if not pm.objExists(name):
raise MayaNodeError, name
slist = OpenMaya.MSelectionList()
slist.add(name)
dagpath = OpenMaya.MDagPath()
slist.getDagPath(0, dagpath)
@taikomatsu
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
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:
points.append(o.getPosition())
particle(p=points, c=1)
print('# done')
View gist:586dc7847517f01f153f
from maya import OpenMaya
from pymel.core import *
def mdagpath_from_name(name, extend_to_shape=False):
if not objExists(name):
raise MayaNodeError, name
slist = OpenMaya.MSelectionList()
slist.add(name)
dagpath = OpenMaya.MDagPath()
slist.getDagPath(0, dagpath)
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
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
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
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
You can’t perform that action at this time.