Well, hopefully you already found the answer, but:

import maya.OpenMaya as om
import maya.cmds as cmds
import maya.mel as mel

selList = om.MSelectionList()
selList.add('persp.rotate')
myPlug = om.MPlug()
selList.getPlug(0, myPlug)
sCmds = []
myPlug.getSetAttrCmds(sCmds, om.MPlug.kAll, True)

print myPlug.name()
print sCmds

rotateMatch = createNode('transform')
select(rotateMatch)

mel.eval(sCmds[0])

... is that roughly what you were looking for?
In general, where the API docs ask for an MString, you can just
substitute in a string, and where they ask for an MString array, you
can substitute in a normal array.  Huzzah!
For more unusual types / the odd situation, you'll have to resort to
OpenMaya.MScriptUtil to create 'pointer objects'.

- Paul


On Wed, Oct 8, 2008 at 11:55 AM, Ravi Jagannadhan <[EMAIL PROTECTED]> wrote:
> Hi all, there's probably a really simple answer for this, but I don't know
> what it is. I'm trying to get a list of the setAttr commands on a plug via
> Python. The Maya API gives you the ability to do this via:
>
>
>
> MPlug::getSetAttrCmds(…)
>
>
>
> Among other things, the function needs an MStringArray reference to be sent
> in. How would I do this in Python when Maya-Python doesn't support MStrings
> (and consequently MStringArrays)? So if I do this:
>
>
>
> # NOTE: Code below assumes existence of an attribute named 'fSmoo' on a node
> named 'pSphere1'
>
> import maya.OpenMaya as om
>
> import maya.cmds as cmds
>
>
>
> cmds.select( 'pSphere1.fSmoo', r=True )
>
>
>
> selList = om.MSelectionList()
>
> om.MGlobal.getActiveSelectionList(selList)
>
> itList = om.MItSelectionList(selList)
>
> myPlug = om.MPlug()
>
> itList.getPlug(myPlug)
>
>
>
> if om.MItSelectionList.kPlugSelectionItem == itList.itemType():
>
>       print myPlug.name()
>
>       myPlug.getSetAttrCmds(sCmds)
>
>
>
> What would 'sCmds' be?
>
>
>
> Thank you for your time,
>
> Ravi
>
> --
> Where we have strong emotions, we're liable to fool ourselves - Carl Sagan.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---

Reply via email to