We are working on command to create textures, but I have a question about where is the best way to save an image in the document. Imagine that I use a bitmap on my computer and I send you the 3DM. I want the users can share the files and edit them.
I was checking and it is available a RhinoDoc.ActiveDoc.Bitmaps, but I can not attach details about the bitmap.
Another idea is to use UserData in the object, and store the bitmap in the geometry, but is not the best if you have 5 textures = 5 times the same image, but, you can Copy-Paste between documents and keep working.
You could store the bitmap in the bitmaps table, store details about it in document or plugin data, and store its name on any objects that use it. For handling copy/paste, that uses a temp 3dm, so you can override your plugin write/read document methods and use the options given (e.g. whether selected objects only should be saved) to determine which bitmaps you should store, in order to be able to restore them later, if/when the document is pasted.
I’m storing bitmaps in the document using WriteDocument with archive.WriteByteArray(byteArray), but do you know if I can add an ID or something to identify it?
A typical way of handling that is to write some metadata, preceding each piece or group of actual data, to describe what will follow. So say you want to write an array of objects, which each knows how to write itself.
archive.WriteInt(objects.Count);
foreach (var o in objects)
o.Write(archive)
Then when reading, you use the metadata you wrote to reconstitute the data:
var nObjects = archive.ReadInt()
var objects = new List<Object>();
for (int i = 0; i < nObjects; ++i)
{
objects.Add(new Object());
objects[i].Read(archive);
}