Skip to content

Instantly share code, notes, and snippets.

@redglasses67
Created December 23, 2022 18:54
Show Gist options
  • Save redglasses67/766e80e2f6ff76f5257b82fe50415754 to your computer and use it in GitHub Desktop.
Save redglasses67/766e80e2f6ff76f5257b82fe50415754 to your computer and use it in GitHub Desktop.
MFnMatrixAttribute での addAttribute
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment