That's because you're trying to get the plug from just the attribute name.
One thing that can be confusing when first starting to use OpenMaya is that
the word "attribute" is used somewhat differently in the api than it is in
mel / maya.cmds... and the api also introduces a new concept, a "plug".

The generally like to think of the difference like that between classes and
instance in maya; an api "attribute" describes a class of attributes, and a
"plug" is like a specific instance of that class.  So, for instance, the
"visibility" attribute describes the qualities of that attribute across all
nodes (ie, whether it is keyable, what sort of data it holds, etc), while a
plug represents one specific instance of that attribute on one specific
node. In fact, it gets even more granular than that - there are different
plugs for inputs and outputs to that attribute (not to mention networked
and non-networked plugs - but that's something I'm not going to dive into
now).

In your case, you've got a specific node, and you're trying to find the
plug associated with an attribute on that node... but since your attribute
is the child of an array attribute (or a "multi" attribute, in mel-speak),
it still doesn't have enough information to get a specific plug for that
attribute.  I sort of wish the api would just error in this situation,
because I think it would be clearer, but instead, it returns a sort of
"placeholder" plug, that just "placeholder" indices (those "-1" indices).
Because it's not pointing at any specific plug, it's really not good for
much (at least as far as I know). You need to get a specific index, for
both it's parent array attributes, before you can do something useful with
it.

However, you haven't made clear which one you're looking for.  Are you
trying to iterate over all instances of that plug (for all indices of both
parent attributes)? Do you just want a plug that actually exists, but you
don't really care which one?  If so, note that it's possible that NO "real"
instances of that plug exists, because one of the parent array plugs might
currently have no members...

On Tue, Feb 2, 2016 at 6:00 AM sergei nazarenko <[email protected]>
wrote:

> Help me ))
>
> I need to get the right name of attribute but Maya gives me wrong (((
>
>
> import maya.OpenMaya as om
>
> # add in selection
> selList = om.MSelectionList()
> selList.add("blendShape1")
> # get MObject
> selObj = om.MObject()
> selList.getDependNode(0,selObj)
> # attach to dependency Fn set
> fnDepend = om.MFnDependencyNode(selObj)
> totalAttrs = fnDepend.attributeCount()
> for i in range(0,totalAttrs):
>     attrObj = fnDepend.attribute(i)
>     fnAttr = om.MFnAttribute(attrObj)
>     if fnAttr.isStorable() and fnAttr.isWritable():
>         plug = fnDepend.findPlug(attrObj)
>         print plug.partialName(True, True, True, False, True, True)
>
> ....
> blendShape1.inputTarget[-1].normalizationGroup[-1].normalizationUseWeights
> ....
>
>
> I need name like
> "blendShape1.inputTarget[0].normalizationGroup[0].normalizationUseWeights"
> . It is how Connection Editor shows given attribute name.
>
> In which way I can get the right indexes?
>
> I would be very appreciated for any help
>
> Sergiy,
> Best
>
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/52c5d426-679e-4b79-bfe9-9df27544ccec%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/52c5d426-679e-4b79-bfe9-9df27544ccec%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAAssL7aSqUVgf58kj-%2BZ-Hs4vWVuw1K_8VY1gfP_rY-X4rQjpA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to