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 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>>; | |
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 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でも/を返す為今回は自分で修正。 |
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
# 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') |
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 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): |
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
# 何らかの理由で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 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 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 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') |
OlderNewer