This file contains hidden or 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
# -*- coding: utf-8 -*- | |
""" | |
参考サイト | |
python - PyQt4 center window on active screen - Stack Overflow | |
https://stackoverflow.com/questions/20243637/pyqt4-center-window-on-active-screen | |
getting all QT/PySide Windows - Google グループ | |
https://groups.google.com/forum/#!topic/python_inside_maya/q245Vh6W7uI | |
""" |
This file contains hidden or 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
import maya.api.OpenMaya as om2 | |
mod = om2.MDGModifier() | |
mod.commandToExecute("polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1;") | |
mod.doIt() |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
import maya.cmds as mc | |
import maya.mel as mel | |
import maya.OpenMaya as om | |
import maya.api.OpenMaya as om2 | |
maya_useNewAPI = True | |
beforeImport_ID = None |
This file contains hidden or 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
using System.Collections; | |
using UnityEngine; | |
using Substance.Game; | |
public class ChangeSubstanceParam : MonoBehaviour | |
{ | |
public SubstanceGraph targetSubGraph; | |
public string inputColorName; | |
public Color color1 = new Color(0.2f, 0.8f, 0.1f, 1.0f); | |
public Color color2 = new Color(0.6f, 0.3f, 0.9f, 1.0f); |
This file contains hidden or 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
import maya.api.OpenMaya as om2 | |
selList = om2.MGlobal.getActiveSelectionList() | |
mDagPath = selList.getDagPath(0) | |
mesh = om2.MFnMesh(mDagPath) | |
# ColorSetの名前一覧を取得 | |
colorSetNames = mesh.getColorSetNames() | |
print(colorSetNames) # stringのTupleで返ってきます |
This file contains hidden or 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
import maya.api.OpenMaya as om2 | |
import maya.OpenMaya as om | |
selList = om2.MGlobal.getActiveSelectionList() | |
mDagPath = selList.getDagPath(0) | |
objectName = om.MFnDependencyNode(mDagPath.transform()).name() | |
# 残念ならがまだ Python API 2.0 の方に MFnExpression クラスが移植されていないようなので1.0の方を使います | |
exp = om.MFnExpression() | |
exp.create("%s.rotateY = time * 10;" % objectName) # 中身はいつものExpressionを書く |
This file contains hidden or 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
import maya.api.OpenMaya as om2 | |
import maya.api.OpenMayaAnim as oma2 | |
selList = om2.MGlobal.getActiveSelectionList() | |
mObject = selList.getDependNode(0) | |
# findPlug を使って取得する場合 | |
dependencyNode = om2.MFnDependencyNode(mObject) | |
transXplug = dependencyNode.findPlug('tx', 0) |
This file contains hidden or 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
import maya.api.OpenMaya as om2 | |
selList = om2.MGlobal.getActiveSelectionList() | |
mDagPath = selList.getDagPath(0) | |
transform = om2.MFnTransform(mDagPath) | |
trs = transform.translation(om2.MSpace.kTransform) | |
print("translation = %s" %trs) | |
trsW = transform.translation(om2.MSpace.kWorld) |
This file contains hidden or 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
import maya.api.OpenMaya as om2 | |
dgModifier = om2.MDGModifier() | |
dgModifier.renameNode(mObject, "hogehoge") # 第1引数は MObject で、第2引数に 変更したい名前 です | |
dgModifier.doIt() # この doIt() を書き忘れると実行されないのでご注意を |