ECToo / pymel

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

i can use Attribute.get()[1] to retrieve the value of an index, but i cant use Attribute.set('newstring')[1] to set the index #239

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Describe the problem.
this may simply be my lack of understanding how to use Attribute.set(), but 
based on the pattern i see of pymel to get and set in the same way, and 
treating an attr like an object.. it seems that i should be able to set an 
index of a stringArray attr the same way i get it.

What Version of Maya are you using?
maya 2011 64bit sp1

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

What Version of PyMEL are you using?
pymel-1.0.0-py2.6egg

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

it would be intuitive of pymel if it let me set the array attribute index the 
same way i get it.

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.

import pymel.core as pm
pynode = pm.nt.Network(n='testNetWorkNode')
pynode.setDynamicAttr('newData',['yo','hey'])
strArryAttr = pm.PyNode('testNetWorkNode.newData')
strArryAttr.get()[1]
# Result: u'hey' #

strArryAttr.set('heyThere')[1]
# RuntimeError: # 

Does maya.cmds exhibit the same problem?

not applicable..

Please provide any additional information below.

i very well may just not understand how to do this, or it may simply not be 
possible.
i would preffer not to use a string multiAttr in this case, or the setAttr 
command,
i would like to be able to manipulate the string array attr as a pyNode.

it would be sufficient if i had to get pynodes for each element of the 
stringArray attr, thought his would not be ideal.. i just dont know how to do 
that yet either..

thanks!

Original issue reported on code.google.com by mark_the...@yahoo.com on 14 Mar 2011 at 9:02

GoogleCodeExporter commented 9 years ago
btw, i realize that 
strArryAttr.get()[1]

is just python at work, and not anything special pymel is doing.
nevertheless, it would be great to know how to use .set() to set a specific 
index of a stringArray attr.

(i also realize that i could set the value of the array outside the attr, and 
set the whole thing again.. but again, i wonder if i can change an individual 
index in place?)

Original comment by mark_the...@yahoo.com on 15 Mar 2011 at 1:45

GoogleCodeExporter commented 9 years ago
Unfortunately, maya provides no way to set just a single value in a *Array type 
attribute; if this is needed or desired, you should use an array (aka, multi) 
attribute of the desired type.
While it would be possible to provide a pymel wrapper which would make it seem 
like you're setting only a single item, under the hood it would have to set the 
whole array; and if this is the case, I'd rather not hide the fact.

Original comment by elron...@gmail.com on 30 Mar 2011 at 7:17

GoogleCodeExporter commented 9 years ago
thanks elron.. 
i thought as much, and i totally understand the premise of pymenl not to hide 
all the short-commings.. only the really big ones right?

this was an issue for me back in maya 1.5 beta! i went round and round with 
alias wavefront about the confusion and subtle difference between Array And 
multi, and i asked them to just make them one and the same.. a more 
generalized, useful and understandable data model. but all i got back 
was....crickets....

so i have worked around it.. but i still cringe that people, to this day, call 
multi attrs "arrays".. when they are not array attrs at all.. they dont behave 
the same way and they dont do the same thing in every case, and they are 
documented separately.

i would love it if pymel would make this distinction more clearer in its own 
documentation... several times, even in your last post, you called a multiAttr 
and array.. and its not.

thanks

Original comment by mark_the...@yahoo.com on 31 Mar 2011 at 3:11