1

I would like to know if it's possible to save values using Mel or python. For example, I am using :

int $a = 5;
int $b = 4;
string $declare = ( "matrix $m[" + $a + "][" + $b + "];" );
eval $declare;
$m[0][1] = 1;
//etc..

And so forth, so I can modify values in it, but the storage has a limitation. Is it possible to save data in Maya, maybe by saving them is a single file? Thanks for any response!

SirJames
  • 387
  • 8
  • 27
  • Do you need to save this value into the file in between sessions? – theodox Dec 06 '16 at 21:31
  • not necessarily – Hector Piteau Dec 06 '16 at 22:00
  • So are you looking a way to save a data with maya file itself ? if so you can use fileInfo command .. cmds.fileInfo('myattribute', value) .. so this will save data with maya file – Achayan Dec 07 '16 at 00:36
  • you can also add the needed info on custom attributes, (global Node) and save the file incl. your Value OR add meta data on the selected Node https://help.autodesk.com/cloudhelp/2016/CHS/Maya-Tech-Docs/CommandsPython/applyMetadata.html – Ari Gold Dec 07 '16 at 09:39
  • So with fileInfo, can I save 1000 coordonate of vertices for exemple ? To use them in the futur ? – Hector Piteau Dec 07 '16 at 12:31
  • You can write out a text file and parse it back later. I used this method to export and import meshes using PyYAML. – UKDP Dec 12 '16 at 14:42

1 Answers1

1

If you want to save arbitrary data inside a file, use the fileInfo command. By default fileInfo only saves strings or numbers, but you can convert any data type you need to something fileInfo can use by saving it to, say, a JSON object and stashing a text dump of the JSON object in the fileInfo. This question includes an example which uses fileInfo to store a lot of zipped binary data inside a fileInfo; the link in the question includes example code showing how it works.

Don't forget that Maya is optimized for working with geometry data. You can also store your points, for example, as an actual maya mesh object in an mb or ma file and then import it and query it. That will usually be faster than imventing your own format to do things Maya already does well

Community
  • 1
  • 1
theodox
  • 12,028
  • 3
  • 23
  • 36