oh i know pretty much every part of the api related to animation / rigging.
Im just pointing out that in order to use the API in python you have to 
follow some strict procedure ( automatic binding with swig)

import maya.OpenMaya as OpenMaya
def getMObject(nodeName):
    selList = OpenMaya.MSelectionList()
    OpenMaya.MGlobal.getSelectionListByName(nodeName,  selList)
    depNode = OpenMaya.MObject()
    selList.getDependNode(0, depNode) 

    return depNode
    

nodeFn = OpenMaya.MFnDependencyNode(getMObject('joint1'))
matrixPlug = nodeFn.findPlug('rotatePivot')

for childIndex in range(matrixPlug.numChildren()):
    print matrixPlug.child(childIndex).asFloat()


Hence me getting a plug from dependency Mfn function set and not fiddling 
with the MSelectionList ( which conceptually is for dag/dependency and 
components).
Most of the time when working with python programmer, or other artist i 
have to point out that the api is exposed and use some python syntax but 
you must adopt maya philosophy ( so asking for more pythonic doesnt make 
sense  : at some point
you will write it in c++ and your python code will be a waste of time to 
translate back to pure API)

Le jeudi 28 juin 2018 17:05:19 UTC+1, Rémi Deletrain a écrit :
>
> I want to get a vector attribute like *translate*.
> Attribute *translate* and *rotatePivot* is a same type. But get 
> rotatePivot doesn't work and get translate works fine.
>
> from maya import OpenMaya
>
> def get_mplug(s_attr_node):
>     m_sl = OpenMaya.MSelectionList ()
>     m_sl.add (s_attr_node)
>     mp = OpenMaya.MPlug ()
>     m_sl.getPlug (0, mp)
>     return mp
>
> try:
>     mp_translate = get_mplug("joint1.translate")
>     print mp_translate.child(0).name()
>     print mp_translate.child(1).name()
>     print mp_translate.child(2).name()
> except:
>     print "Get translate doesn't works"
> else:
>     print "Get translate works"
>
> try:
>     mp_rotate_pivot = get_mplug("joint1.rotatePivot")
>     print mp_rotate_pivot.child(0).name()
>     print mp_rotate_pivot.child(1).name()
>     print mp_rotate_pivot.child(2).name()
> except:
>     print "Get rotatePivot doesn't works"
> else:
>     print "Get rotatePivot works"
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/9510eb6d-579a-4cdd-9992-54bd53158ce3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to