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
Shader "Dynamic Branch Shader Simple" | |
{ | |
Properties | |
{ | |
_TexAAA ("Tex AAA", 2D) = "white" {} | |
_TexBBB ("Tex BBB", 2D) = "white" {} | |
_TexCCC ("Tex CCC", 2D) = "white" {} | |
[KeywordEnum(None, AAA, BBB, CCC)] _Var_Test ("Variant Test", Float) = 1 | |
} |
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
Shader "Dynamic Branch Shader Complex" | |
{ | |
Properties | |
{ | |
_TexAAA ("Tex AAA", 2D) = "white" {} | |
_TexBBB ("Tex BBB", 2D) = "white" {} | |
_TexCCC ("Tex CCC", 2D) = "white" {} | |
[KeywordEnum(None, AAA, BBB, CCC)] _Var_Test ("Variant Test", Float) = 1 | |
} |
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) | |
floatAttr = om2.MFnNumericAttribute() | |
floatAttrObj = floatAttr.create("floatLongName", "floatShortName", om2.MFnNumericData.kFloat, 1.0) | |
# create後じゃないと設定できない | |
floatAttr.writable = 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) | |
enumAttr = om2.MFnEnumAttribute() | |
enumAttrObj = enumAttr.create("enumLongName", "enumShortName", 0) | |
enumAttr.addField("AAA", 0) | |
enumAttr.addField("BBB", 1) |
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) |
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) | |
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 | |
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.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 | |
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)) |