Skip to content

Instantly share code, notes, and snippets.

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