I am running a simple script which creates 2 attributes (instanceIndex and instanceScale) on 3 particles that I create through a simple Python script. Once I run the script, I can see the attributes and their correct values after I select them in the Component Editor. Everything looks correct then, however when I close my scene and reopen it, I completely loose my instanceScale attribute and I loose the values that I have inserted for my instanceIndex. I have ran this through a number of changes, and can’t seem to figure out why I am loosing those values.
Here is the code I am running. My main goal is to add abitrary attributes to an nParticle object through a Python script, and for them to not be lost when I save and open the scene. Thank you very much in advance.
#Maya
from maya import cmds
ptList = [0, 1, 2]
particleNode = cmds.nParticle(p={(1, 0, 0), (0, 1, 0), (0, 0, 1)}) #u'particle1', u'particleShape1']
#asset assignment
cmds.addAttr(particleNode[1], ln='instanceIndex', dt='doubleArray')
cmds.addAttr(particleNode[1], ln='instanceScale', dt='vectorArray')
#go through each particle
for pt in ptList:
cmds.nParticle(particleNode[1],e=True,attribute = "instanceIndex",id=pt, fv = 2)
cmds.nParticle(particleNode[1],e=True,attribute = "instanceScale",id=pt, vv = (2, 2, 2))
print "+++++++++"
print cmds.nParticle(particleNode[1],q=True,attribute = "instanceIndex",id=pt)
print cmds.nParticle(particleNode[1],q=True,attribute = "instanceScale",id=pt)
Also, I am using this script to query a point to check my particle attributes when I reopen the scene. You can also use the Component Editor as well.
print cmds.nParticle('nParticleShape1',q=True,attribute = "instanceScale",id=0)