Thanks for the help Justin. I didnt realize pymel.addAttr wasn't
actually creating the attrs.
I just ended up switching to the maya.cmds module. Here is an
example:
import maya.cmds as mc
pPos = [ (0,1,0), (0,2,0), (0,3,0) ]
mc.particle(p=pPos)
mc.addAttr('particleShape1', longName='rgbPP', dataType='vectorArray')
mc.particle('particle1', e=True, attribute='rgbPP', id=0, vv=[1,0,0])
mc.particle('particle1', e=True, attribute='rgbPP', id=1, vv=[0,1,0])
mc.particle('particle1', e=True, attribute='rgbPP', id=2, vv=[0,0,1])
As you pointed out this is slow but it is fast enough for the datasets
I'm working with. Will look into particle caches next.
Thanks,
-pro
On Jan 21, 8:01 am, Justin Rosen <[email protected]> wrote:
> 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