Export C++

Hi,

I used to call the exporter from python. Now I’m porting the code to C++ but nothing happens.
Here is what I do:

	unsigned int rhino_doc_sn = context.m_doc.RuntimeSerialNumber();
	CRhinoObjectIterator it(
		rhino_doc_sn,
		CRhinoObjectIterator::undeleted_objects,
		CRhinoObjectIterator::active_and_reference_objects
	);

	for (CRhinoObject* rhino_obj = it.First(); rhino_obj != nullptr; rhino_obj = it.Next())
	{
		rhino_obj->Select();
	}

	context.m_doc.Redraw();
	ON_wString script;
	script.Format(L"! _-Export \"%ls\" _Enter", filename.Array());
	RhinoApp().Print(script + "\n");
	RhinoApp().RunScript(context.m_doc.RuntimeSerialNumber(), script);

If I copy/paste the command I print directly in Rhino, it works, but if it’s done through RunScript in C++, I only get “Command: _-Export”, no progress bar, no file created.

I tried other type of file with the same result.

I tried the CSampleScriptCancelHelper and it returns success.

Thanks!
– Paul

Have you made the command able to run scripts? You should inherit from CRhinoScriptCommand, see

1 Like

You solved it!
Thank you so much.

– Paul

1 Like