ECToo / pymel

Automatically exported from code.google.com/p/pymel
0 stars 0 forks source link

"Force" flag on setAttr not creating attribute #250

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Describe the problem.

"Force" flag on set (setAttr) causes AttributeError

What Version of Maya are you using?
maya 2011

On what operating system? (be as specific as possible and include service
packs, 64bit vs 32bit, etc)
Mac os 10.6.6

What Version of PyMEL are you using?

__version__ = '1.0.0'

What is the expected output? What do you see instead?

If possible, provide a few lines of code to reproduce the problem. It helps
us if your code will reproduce the problem from a new scene.

node=pymel.core.general.PyNode(pymel.core.selected()[0])
node.newAttribute.set(0,f=1)
# AttributeError: nt.Transform(u'null1') has no attribute or method named 
'newAttribute' #

Does maya.cmds exhibit the same problem?

Please provide any additional information below.

Original issue reported on code.google.com by noahmizr...@gmail.com on 11 Jul 2011 at 5:50

GoogleCodeExporter commented 9 years ago
Hi!

What is the "newAttribute" command? Never used that one.

Maybe try the standard Maya addAttr via pymel?

node.addAttr(<insert definition here>).set(0, f=1)

Even if newAttribute was a cmd you are not supplying the definition of the new 
attribute. No name, or type seems to be defined.

Cheers.

Original comment by amor...@gmail.com on 11 Jul 2011 at 3:16

GoogleCodeExporter commented 9 years ago
Yes... you have to first create the attribute with addAttr before you can 
access it with the property syntax. (ie, call node.addAttr('newAttribute') 
before you can call node.newAttribute).
To use setAttr with the force flag, you would have to explicitly call the 
setAttr command, not the Attribute.set method:

setAttr('myNode.newAttribute', False, f=1)

Original comment by elron...@gmail.com on 11 Jul 2011 at 3:31

GoogleCodeExporter commented 9 years ago
It's in the docs as a modification:

Added ‘force’ kwarg, which causes the attribute to be added if it does not 
exist. 

http://pymel.googlecode.com/svn/docs/generated/classes/pymel.core.nodetypes/pyme
l.core.nodetypes.Attribute.html?highlight=attribute#pymel.Attribute

Original comment by noahmizr...@gmail.com on 12 Jul 2011 at 7:17

GoogleCodeExporter commented 9 years ago
I should also mention Ofer Koren implemented this at Image Movers. Why is it in 
the docs as a modification but not as part of the current release?  I hope you 
guys will consider it, it's one of the key points of pymel I demonstrate  to 
python or mel users. 

Original comment by noahmizr...@gmail.com on 12 Jul 2011 at 7:21