Heya

Aaaa the pickle module. I remember it now ! There is also cPickle if I'm not 
wrong which is a lot faster but then again... I should be fine for my basic 
stuff..

In any case I got it saving and loading which is great. But I naturally hit a 
wall with re-assigning the data back to objects (materials in my case).

Can any1 have a look at it and let me know where I go wrong? 

I think its because I try to iterate through list with another list so that my 
changes that I load end up being the last iterated value rather than what it 
should be, is there a way to somehow sync it ? Atm I only got 1 value but what 
will I do if there is RGB or a texture plug in to it, oh noez I'm screwed :D

Anyway thanks for pickle hint! :)

import pickle

### Exporting
values = []

sel=cmds.ls(sl=1,mat=1)
for materials in sel:
        diffColorAmmount= cmds.getAttr(materials+'.diffuseColorAmount')
        values.append(diffColorAmmount)

clearfileValue = open("c:/MayaStore/MaterialValues.p", 'w')
clearfileSel = open("c:/MayaStore/MaterialSel.p", 'w')
clearfileValue .close()
clearfileSel.close()
pickle.dump(values, open( "c:/MayaStore/MaterialsValue.p", "wb" ) )
pickle.dump(sel, open( "c:/MayaStore/MaterialsSel.p", "wb" ) )


### Importing

valList = pickle.load( open( "c:/MayaStore/MaterialsValue.p", "rb" ) )
selList = pickle.load( open( "c:/MayaStore/MaterialsSel.p", "rb" ) )

for objects in selList:
        for NewVal in valList:
                cmds.setAttr(objects+ '.diffuseColorAmount', NewVal)

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to