figured it out

plug  = MGlobal.getSelectionListByName('node.attr').getPlug(0)
dummy = MFnStringArrayData().create(['foo', 'bar'])
plug.setMObject(dummy)


Le lundi 12 août 2019 00:12:48 UTC-4, vince touache a écrit :
>
> hi folks, 
>
> For optimisation purpose, I'm trying to write/read some stringArray 
> attributes. Never had any issue to do that in cpp, and it works fine in 
> python as well for reading, but I can't figure out how to write this 
> attribute with python, since it doesn't include any MStringArray (unlike 
> MPointArray or other type of maya arrays).
> Right now, I have :
> # create a dummy stringArray plug
> sph = cmds.polySphere(ch=0)[0]
> cmds.addAttr(sph, ln='foo', dt='stringArray')
> strplug = '.'.join((sph, 'foo'))
> # get the function set
> sel=MGlobal.getSelectionListByName(strplug)
> hPlug=sel.getPlug(0).asMDataHandle()
> fn=MFnStringArrayData(hPlug.data())
> # fail to do anything with it.... also, noticed that by default it seems 
> to error instead of returning an empty array..
> fn.set('bar')
>
> anyone has done that before ? What am I missing ? 
>
> Thanks a lot
>
>

-- 
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/1366965c-3526-4c23-a4ac-9028b673dfad%40googlegroups.com.

Reply via email to