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.api.OpenMaya as om2 | |
from typing import List, Dict | |
def findConnectedVtxIndexes(targetVtxIndex: int, srcVtxIndexDict: dict, shellVtxIdList: list) -> list: | |
""" | |
srcVtxIndexDict 内で targetVtxIndex と繋がっている頂点のインデックスを探す. | |
繋がっているものは同じシェル内にある頂点となる. |
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.cmds as mc | |
import maya.mel as mel | |
def displayFloatAttrAnnotation(offsetY=0): | |
selList = mc.ls(sl=True) | |
if len(selList) == 0: | |
mc.warning("Please select any object...") | |
return | |
channelBox = mel.eval('global string $gChannelBoxName; $temp=$gChannelBoxName;') |
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 | |
dependencyNodes = om2.MItDependencyNodes() | |
while not dependencyNodes.isDone(): | |
currentNode = dependencyNodes.thisNode() | |
dependencyNode = om2.MFnDependencyNode(currentNode) | |
print("name = {} : typeName = {}".format(dependencyNode.name(), dependencyNode.typeName)) | |
dependencyNodes.next() |
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.OpenMayaAnim as oma2 | |
# アニメーションの開始終了フレームを取得 | |
animationStartTime = oma2.MAnimControl.animationStartTime() # アニメーションの開始フレーム | |
print("animationStartTime = {} - {}".format(animationStartTime, animationStartTime.asUnits(animationStartTime.uiUnit()))) | |
animationEndTime = oma2.MAnimControl.animationEndTime() # アニメーションの終了フレーム | |
print("animationEndTime = {} - {}".format(animationEndTime, animationEndTime.asUnits(animationEndTime.uiUnit()))) | |
minTime = oma2.MAnimControl.minTime() # 再生範囲の開始フレーム |
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() | |
mObject = selList.getDependNode(0) | |
depNode = om2.MFnDependencyNode(mObject) | |
for i in range(depNode.attributeCount()): | |
attribute = depNode.attribute(i) | |
mPlug = depNode.findPlug(attribute, 0) | |
print("name = {} : type = {}".format(mPlug.partialName(useLongNames=True), attribute.apiTypeStr)) |
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.OpenMaya as om | |
selList = om2.MGlobal.getActiveSelectionList() | |
mObject = selList.getDependNode(0) | |
dagNode = om2.MFnDagNode(mObject) | |
# ルートを取得 | |
# ※ これで取得できるのは、シーン内には見えない本当のトップノード | |
# なので、下記のようにこのオブジェクトの子を取得すると perspカメラ や topカメラなどが得られる | |
topDagNode = om2.MFnDagNode(dagNode.dagRoot()) |
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 | |
matName = "lambert1" | |
matNodes = om2.MGlobal.getSelectionListByName(matName) | |
mObject = matNodes.getDependNode(0) | |
depNode = om2.MFnDependencyNode(mObject) | |
outPlug = depNode.findPlug("outColor", 0) | |
dstPlug = outPlug.destinations() | |
set = om2.MFnSet(dstPlug[0].node()) | |
members = set.getMembers(True) |
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() | |
mObject = selList.getDependNode(0) | |
fnDepNode = om2.MFnDependencyNode(mObject) | |
floatLongName = "floatLongName" | |
dstAttrPlug = fnDepNode.findPlug(floatLongName, False) | |
if fnDepNode.hasAttribute(floatLongName): |
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() | |
mObject = selList.getDependNode(0) | |
fnDepNode = om2.MFnDependencyNode(mObject) | |
stringAttr = om2.MFnTypedAttribute() | |
stringAttrObj = stringAttr.create("stringLongName", "stringShortName", om2.MFnData.kString) | |
stringAttr.default = om2.MFnStringData().create("a b c d e f g") | |
fnDepNode.addAttribute(stringAttrObj) |
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() | |
mObject = selList.getDependNode(0) | |
fnDepNode = om2.MFnDependencyNode(mObject) | |
matrixAttr = om2.MFnMatrixAttribute() | |
matrixAttrObj = matrixAttr.create("matrixLongName", "matrixShortName", om2.MFnMatrixAttribute.kDouble) | |
matrixAttr.default = om2.MMatrix([(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1)]) | |
fnDepNode.addAttribute(matrixAttrObj) |
NewerOlder