“”"
Shorthand:
The shorthand method is the most visually appealing and readable – you simply access the maya attribute as a normal python attribute – but it has one major drawback: if the attribute that you wish to access has the same name as one of the attributes or methods of the python class then it will fail.
“”"
i don’t understand why there would be a conflict, since the methods would belong to different objects. Which means, two attributes or methods could have the same name if they belong to(are on) different objects…or…what does the part where its bold really mean?
can someone shed some light on this for me please…?
[QUOTE=Thios;13476]
i don’t understand why there would be a conflict, since the methods would belong to different objects. Which means, two attributes or methods could have the same name if they belong to(are on) different objects…or…what does the part where its bold really mean?
can someone shed some light on this for me please…?
thanks…[/QUOTE]
I’ve actually run into this once or twice, the short answer is that it has to do with how PyNodes are subclassed from specific Python objects. The specific example I’ve run into is with a nurbsTesselate node (pymel.core.nodetypes.NurbsTesselate).
If you look at a nurbsTesselate’s attributes, you’ll see it has an attribute called “format”, which if i remember correctly has to do with how it outputs geometry. Next, take a look at pymel.core.nodetypes.NurbsTesselate’s class hierarchy. You’ll see that the base class is something called pymel.util.utilitypes.ProxyUnicode. If you browse through its attribute list, you’ll see it also has a “format” attribute, in this case i believe it’s analogous to string.format(). So if you spawn an instance of pymel.core.nodetypes.NurbsTesselate and try to call a .format.set(), the interpreter will gripe at you about trying to improperly access .format, since it thinks you’re trying to access pymel.util.utilitytypes.ProxyUnicode.format(), as opposed to pymel.core.nodetypes.NurbsTesselate.format.
That’s a pretty specific example, and really the only time i’ve ever run into it, but it DOES happen!:laugh: So if you ever try and access a PyNode’s Maya attribute and you get a weird access error, you may just want to double check and be sure you don’t need to spawn an instance of the attribute directly. Depending on what you’re trying to do and how much you need to access said attribute, may just be easier to use a setAttr for that specific instance.