Skip to content

Instantly share code, notes, and snippets.

@nrtkbb
nrtkbb / githubSearchCode.py
Last active August 29, 2015 14:13
github apiでmaya.cmdsを検索した結果からリポジトリをリストアップして、スター数でソートしようとしたら、github apiでは全体検索がサポートされてなかったw
#coding:utf-8
import urllib
import urllib2
import cookielib
import json
# python :: urllib2 でhttps通信したときのめも - ichirin2501の日記
# http://d.hatena.ne.jp/ichirin2501/20110428/1303924574
#
# ssl通信を行う場合に必要。
#!/usr/bin/env python
# -*- coding=utf-8 -*-
import sys
import os
import subprocess
from datetime import datetime
def exists_check(path):
if not os.path.exists(path):
@nrtkbb
nrtkbb / cv0pivots.py
Last active August 29, 2015 14:15
[Maya] NurbsCurveを選択して実行するとCV0の位置にピボットを移動するやつ
import pymel.core as pm
for trans in pm.ls(sl=True):
shape = trans.getShape()
if not type(shape) == pm.nodetypes.NurbsCurve:
print ('{} is not NurbsCurve. skipped.'.format(shapw.longName()))
continue
trans.setPivots(shape.getCV(0))
@nrtkbb
nrtkbb / cluster_copy.py
Last active August 29, 2015 14:16
WIP [Maya] clusterのコピーとミラーコピー
# -*- coding: utf-8 -*-
import pymel.core as pm
import re
from itertools import chain
def divide_select_list(selectlist):
if 2 > len(selectlist):
raise Exception(u'Please select clusters and mesh.')
@nrtkbb
nrtkbb / optionsWindow.py
Created March 22, 2015 11:04
Maya Python完全リファレンスに載っているAR_OptionsWindowクラスのpymel版
class optionsWindow(object):
"""
optionsWindow base class.
"""
def __init__(self):
self.name = 'optionsWindow'
self.title = 'Options Window'
self.supportsToolAction = False
self.actionName = 'Apply and Close'
@nrtkbb
nrtkbb / nurbsToPolySp.py
Last active August 29, 2015 14:17
nurbsSurfaceと同じ階層にnurbsToPolyするやつ
# -*- coding: utf-8 -*-
import pymel.core as pm
import os
import json
class OptionsWindow(object):
"""
optionsWindow base class.
"""
@nrtkbb
nrtkbb / jsonfile.py
Last active August 29, 2015 14:17
データをjsonに書き出したり読み込んだりするクラス
import json
import os
class JsonFile(object):
def __init__(self, file_name):
self.file_name = file_name
def save(self, **kwds):
try:
{
"class": "Node",
"id": "@0x10B9961D0",
"name": "___root___",
"parent": "None",
"nodetype": "None",
"children": [
{
"class": "Node",
"id": "@0x10B9800D0",
@nrtkbb
nrtkbb / selectEmptyHair.py
Created March 28, 2015 14:38
follicleがないhairSystemとpfxHairを見つけて選択するやつ
# -*- coding: utf-8 -*-
import pymel.core as pm
def selectEmptyHairs():
hairs = pm.ls(type='hairSystem')
if len(hairs) is 0:
pfxs = pm.ls(type='pfxHair')