I dealt with this when writing a ptx2pdc. I think I wrote it using Pymel 0.9
so I'm not sure if any of the bugs have been fixed since then. I couldn't
create the rgbPP attributes nor set the rgbPP through python. I ended up using
a mel.eval
> pm.addAttr(pts[0].longName(), longName='rgbPP', dataType='vectorArray')
This doesn't actually create the attrs, check it!
for attr in pm.cmds.particle(str(pts[1]), query=True, dal=True):
print attr
pm.mel.eval('addAttr -ln "rgbPP" -dt vectorArray %s' % pts[1].name())
pm.mel.eval('addAttr -ln "rgbPP0" -dt vectorArray %s' % pts[1].name())
You'll have to do the same when setting the color attrs as well.
Depending on what you're doing there's also much faster ways to go about this.
Are you bringing a large dataset into maya? Maya's very slow when it comes to
setting attrs on large sets of data. It's much faster to write out a particle
cache, create a particle system and point it to the cache.
Hope this helps,
Justin
On Jan 19, 2010, at 11:00 PM, pro wrote:
> I'm having trouble using the setPerParticleAttribute() method to set
> the colors of individual particles in a particle system. Here is an
> example script:
>
> import pymel as pm
> pm.newFile(f=1)
> pPos = [ (0,1,0), (0,2,0), (0,3,0) ]
> pts = pm.particle(p=pPos)
> pm.addAttr(pts[0].longName(), longName='rgbPP',
> dataType='vectorArray')
> pCol = [ (1,0,0), (0,1,0), (0,0,1) ]
> pts[1].setPerParticleAttribute('rgbPP', pCol)
>
> The call to setPerParticleAttribute method throws the following
> exception:
> Error: RuntimeError: (kInvalidParameter): Unknown type
>
> Am I using setPerParticleAttribute() incorrectly? Any pointers would
> be greatly appreciated. Thanks.
> --
> http://groups.google.com/group/python_inside_maya
--
http://groups.google.com/group/python_inside_maya