Howto retrieve plugin specific document data


i store plugin specific data in a document via the CRhinoPlugIn::WriteDocument event which works fine within the plugin.
Now i have a situation where i want to read the 3dm file without opening it and i use at the moment following code:

	FILE* archive_fp = ON::OpenFile(file3dm, L"rb");
	if (0 == archive_fp)
	ON_BinaryFile archive(ON::archive_mode::read3dm, archive_fp);
	ONX_Model model;
	bool rc = model.Read(archive);
	for (int i = 0; i < onxModel.m_object_table.Count(); i++)
		const ONX_Model_Object& model_obj = onxModel.m_object_table[i];



Is it possible to get the document data which was written with CRhinoPlugIn::WriteDocument also with ONX_Model?

Hi @dsw,

This this Rhino 5 or 6?

– Dale

In the end i have to implement it for both. any example would help…

Hi @dsw

Attached is a sample that demonstrates how to read a plug-in’s document user data from 3dm files without the use of Rhino. The sample comes in the form of a plug-in project that writes document data when you have a file. To read the document data, just run the command. The code in the command, however, only requires openNURBS.

The code works Rhino/openNURBS 6. My guess is there some minor refactoring to get this to work with Rhino/openNURBS 5.

Let me know if you have any questions. (32.8 KB)

– Dale

1 Like

Hi @dale

thank you for this sample it helped me again to solve my problem :ok_hand:.
Even though i had to change some details, not only because of Rhino V5/V6 differences, also because i do not use BeginWrite3dmChunk / BeginRead3dmChunk to write my user defined data.

Thank you very much :love_you_gesture: