Skip to content

Instantly share code, notes, and snippets.

import math
def my_sin(x):
e = x
f = 1.0
t = 0.0
for i in range(1, 100):
if i % 2 == 1:
t += e / f
import numpy as np
import copy
from pprint import pprint
# 目的行の列が0だった場合に入れ替える
def swap_row(mtx, rev_mtx, row, col):
num = mtx[row][col]
if num == 0.0:
org_vec = mtx[row]
org_rev_vec = rev_mtx[row]
from maya import cmds
import imp
from maya.app.general.mayaMixin import MayaQWidgetBaseMixin
try:
imp.find_module('PySide2')
from PySide2.QtWidgets import *
from PySide2.QtGui import *
from PySide2.QtCore import *
except ImportError:
from PySide.QtGui import *
@ShikouYamaue
ShikouYamaue / TestCommand.py
Last active July 13, 2021 02:48
MayaAPI2.0のコマンド作成サンプル
# -*- coding: utf-8 -*-
import sys
import maya.api.OpenMaya as om2
##コマンド名
kPluginCmdName = "testCommand"
def maya_useNewAPI():
##新しいAPIですよという宣言がいるらしい
pass
@ShikouYamaue
ShikouYamaue / ApiArrayFlagSample.py
Created May 12, 2019 05:44
Mayaコマンドの引数に配列を渡して解析するサンプル
# -*- coding: utf-8 -*-
import sys
import maya.api.OpenMaya as om2
#import maya.api.OpenMayaUI as omui
kPluginCmdName = "editorSampleCommand" # MELコマンド名
kShortFlagName = "-ts" # 引数のショートネーム
kLongFlagName = "-test" # 引数のロングネーム
@ShikouYamaue
ShikouYamaue / SampleEditor4.py
Last active April 20, 2019 13:51
Sample Editor 4 MayaAPI2.0 + QTableView + QAbstractTableModel
# -*- coding: utf-8 -*-
from maya import cmds
from maya.app.general.mayaMixin import MayaQWidgetBaseMixin
import maya.api.OpenMaya as om2
import maya.api.OpenMayaAnim as oma2
import time
import imp
try:
imp.find_module('PySide2')
from PySide2.QtWidgets import *
@ShikouYamaue
ShikouYamaue / SampleAbstractTableModel.py
Last active April 20, 2019 13:50
QAbstractTableModel Sample
class SampleTableModel(QAbstractTableModel):
def __init__(self, data, parent=None, influences=None, vertices=None):
super(self.__class__, self).__init__(parent)
self._weight_data = data
self.v_header_list = vertices
self.h_header_list = influences
#ヘッダー設定をオーバーライド
def headerData(self, id, orientation, role):
if orientation == Qt.Horizontal:
@ShikouYamaue
ShikouYamaue / SampleEditor3.py
Last active April 20, 2019 11:14
Sample Editor 3 MayaAPI2.0 + QTableView + QStandardItemModel
# -*- coding: utf-8 -*-
from maya import cmds
from maya.app.general.mayaMixin import MayaQWidgetBaseMixin
import maya.api.OpenMaya as om2
import maya.api.OpenMayaAnim as oma2
import time
import imp
try:
imp.find_module('PySide2')
from PySide2.QtWidgets import *
@ShikouYamaue
ShikouYamaue / SampleEditor2.py
Last active April 20, 2019 11:15
Sample Editor 2 MayaAPI2.0 + QTableWidget
# -*- coding: utf-8 -*-
from maya import cmds
from maya.app.general.mayaMixin import MayaQWidgetBaseMixin
import maya.api.OpenMaya as om2
import maya.api.OpenMayaAnim as oma2
import time
import imp
try:
imp.find_module('PySide2')
from PySide2.QtWidgets import *
@ShikouYamaue
ShikouYamaue / SampleEditor1.py
Last active April 20, 2019 11:15
Sample Editor 1 Cmds + QTableWidget
# -*- coding: utf-8 -*-
from maya import cmds
from maya.app.general.mayaMixin import MayaQWidgetBaseMixin
import time
import imp
try:
imp.find_module('PySide2')
from PySide2.QtWidgets import *
from PySide2.QtGui import *
from PySide2.QtCore import *