Save Userdata

I’m trying to save a document and keep the userdata inside , I’m using this code inside a command, it’s not working, I don’t understand why

        Rhino.FileIO.FileWriteOptions FileWriteOptions = new FileWriteOptions();
        FileWriteOptions.WriteUserData = true;
        bool resultado = doc.WriteFile(filePath, FileWriteOptions);

but if I use it in a direct button then it works and I have access to the userdata in the next opening of the document, any ideas?

check this guide / example / documentation:

does it help ?

if it s just a few junks of inormation,
use the much simpler approach:
User Text on Document or Object Level.

there are also some great infos / links in your old topic


Thanks for the answer, the problem is not storing the user data in the docoment.

This data is saved in the document, and if I save the document using the normal method (save as) the data will be available the next time you open it.

The problem is when the document is saved by the method “doc.WriteFile(filePath, FileWriteOptions);”
next time you open the document the user data is empty.

sorry if I did not understand your question.

2 Ideas - but just guessing:

Is it the same problem if you use Write3dmFile instead of WriteFile?

Is the behaviour the same, for the simple “Physical-Data” - Example ?
make sure all Attributes / Guids are set and are unique…

Seams like [AT]stevebaer or [AT]dale are the persons that can help…

kind regards -tom

Does RhinoDoc.Write3dmFile work any better?

– Dale

Hello @dale

Yes, this work fine, and I think the other work to I was making a mistake :stuck_out_tongue_winking_eye: