Loosing nParticle attributes after save and reopen

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)

I can’t say for certain (as I’ve never worked with nParticles), but my guess is that your particles aren’t being serialized with the scene, and instead are potentially being recreated when you reopen.

Any idea what the data looks like when you save it as a mayaAscii file?

I still get the same results, but I can still see that the attributes are being set if I read the .ma file.
I get the same if I do regular particles as I do with nParticles.

Do you know if there is a workaround or a better way at doing this?

Honestly no idea, I don’t think I’ve ever tried to do anything like that with any kind of particle.
Honestly not touched maya particles this decade :confused: