Hello, here is a script i just wrote, its very slow and i was hoping to try re writing it in spilce for maya and see how that works, its mainly so slow because its creating actual objects and not instancing, and there are many ways this script can be optimized.

I started writing it because I couldent fint a waya in maya with mentalray to color the instanced objects like the rgbPP. Then i though i could do more stuff with it like driving a blend shape in the instance etc.

Anyways here it is if your interested:

#####Particle Instancer #######

###select your particle object and run this
import maya.cmds as cmds
import maya.mel as mel
parName = (cmds.ls(sl=True))[0]
pars = cmds.listRelatives(s=True)
print pars

cmds.addAttr('nParticleShape1',ln='rotPP', dt='vectorArray')
cmds.dynExpression( pars[0], s="vector $velocity = .velocity;float $angBet[] = `angleBetween -euler -v1 1 0 0 -v2 ($velocity.x) ($velocity.y) ($velocity.z)`;.rotPP = > ;", rbd=1 )

#Select obeject you want to instance and run this
inst = cmds.ls(sl=True)[0]
instSp = cmds.listRelatives(s=True)[0]

#then run the rest of this
cr = 0

#set frame range to bake
for i in range(1,100):
pId = []
currentTime (i,edit=True)

#Count total particles at sertain point in time
totalParticle = cmds.nParticle( 'nParticle1', query=True, count=True)

#fint the largest particle id in the total particle count through the max function in python
if (totalParticle > 0):
pId = []
for lA in range(totalParticle):
pId += cmds.nParticle( 'nParticle1', query=True, attribute='particleId', order=lA)
theMax = int(max(pId))+1

###Creator of instances and shader
for o in pId:
if cr < theMax:
dup += cmds.duplicate(inst,un=True,rr=True)

cmds.setKeyframe( "%s%d"%(inst,cr), v=0 , attribute='visibility', time=(i-1))
cmds.setKeyframe( "%s%d"%(inst,cr), v=1 , attribute='visibility', time=i)

#create shader and connect /could maybe be done faster
dupShape = cmds.listRelatives("%s%d"%(inst,cr),s=True)[0]
cmds.createNode( 'lambert', n='instancer_%s'%(cr) )
cmds.sets(r=True, empty=True,noSurfaceShader=True, n="instancerSet_%s"%(cr) )
cmds.connectAttr( '%s.instObjGroups[0]'%(dupShape), 'instancerSet_%d.dagSetMembers[0]'%(cr) )
cmds.connectAttr( 'instancer_%d.outColor'%(cr), 'instancerSet_%d.surfaceShader'%(cr) )
cmds.setAttr('instancer_%s.color'%(cr), 1, 1, 1, type="double3")

#find out if visibility of dupicated objects is on, and if on check if its in particle count list, and if s
#check if livning particles are in group
for s in range(len(dup)):
vis = cmds.getAttr("%s.visibility"%(dup[s]))
if s not in pId:
if vis == 1:
cmds.setKeyframe( "%s"%(dup[s]), v=0 , attribute='visibility', time=i)

pIdI = 0
for s in pId:
cnt = s + 1
pPos= cmds.nParticle( parName, q=True, attribute='position', id=s )
rotPos= cmds.nParticle( parName, q=True, attribute='rotPP', id=s )
col= cmds.nParticle( parName, q=True, attribute='rgbPP', id=s )

#set translation of instance
cmds.setKeyframe( "%s%d"%(inst,int(cnt)), v=pPos[0], attribute='translateX', t=i )
cmds.setKeyframe( "%s%d"%(inst,int(cnt)), v=pPos[1], attribute='translateY', t=i )
cmds.setKeyframe( "%s%d"%(inst,int(cnt)), v=pPos[2], attribute='translateZ', t=i )
#setRotation of instance
cmds.setKeyframe( "%s%d"%(inst,int(cnt)), v=rotPos[0], attribute='rotateX', t=i )
cmds.setKeyframe( "%s%d"%(inst,int(cnt)), v=rotPos[1], attribute='rotateY', t=i )
cmds.setKeyframe( "%s%d"%(inst,int(cnt)), v=rotPos[2], attribute='rotateZ', t=i )
#set color in shader
cmds.setAttr('instancer_%s.incandescence'%(int(cnt)), col[0], col[1], col[2], type="double3")
cmds.setKeyframe( 'instancer_%s'%(int(cnt)), attribute='incandescence' )

#####Add an extra pp value to get this to work.
bShape = int(cnt) + 1
cmds.setKeyframe( "blendShape%s.pCube1"%(bShape), v=col[0], attribute='pCube',t=i)

#########Expression to go with

// Get and set particle position
float $pos[] = nParticleShape1.position;
setAttr closestPointOnMesh1.inPosition $pos[0] $pos[1] $pos[2];

// Grab the U and V position of each particle
float $u = `getAttr closestPointOnMesh1.parameterU`;
float $v = `getAttr closestPointOnMesh1.parameterV`;

// Stick those values in the colorAtPoint
float $rgb[] = `colorAtPoint -o RGB -u $u -v $v checker1`;

// Prepare and apply RGB values to your pa

Loading more stuff…

Hmm…it looks like things are taking a while to load. Try again?

Loading videos…