Copy/Paste to/from clipboard

Up to release 6.0 were able to pass data from our app and get data
from Rhino with a copy/past to clipboard using opennurbs to write-read the buffer.
Something has changed and it does not work in v 7.0 , can we have a example on how to do this ?

thanks
Gerry

Hi @gerryark,

Do you have some code, that doesn’t work, that you can share?

Thanks,

– Dale

Here a snippet for reading, I have a similar for Writing
they both work fine with Rhino 6
Model.read fails to read from the stream

void uimain::cmGetRhinoData( bool bSilent )
{
	QClipboard *clipboard = QApplication::clipboard();
	const QMimeData * mimeData = clipboard->mimeData(  );
	QStringList	formats = mimeData->formats();
	for(int k=0;k<formats.size();k++)
	{
		QString cformat = formats[k];
		//QStringList items = cformat.split("=");
		//if (items.size() > 1)cformat = items[1];

		if( cformat.contains(QString("Rhino 4.0 3DM Clip global mem")) || cformat.contains(QString("Rhino 5.0 3DM Clip global mem")) || cformat.contains(QString("Rhino 6 3DM Geometry"))|| cformat.contains(QString("Rhino 7 3DM Geometry")) )
		{
			QByteArray data = mimeData->data ( cformat );
			QRhinoDataStream stream(data);
			ONX_Model model;
			if(  model.Read(stream) )
			{
			  IW_ReadRhinoFile( &model  , GetStruttura() , NULL , bSilent );
			  return;
			}
		}
	}
}

Hi @gerryark,

Here is a sample that shows how to paste, basically.

cmdSamplePaste.cpp

It is intentionally verbose, and it does not read from a stream but rather from a temporary file.

Does this help?

– Dale

Thanks Dale
Could I have a example on how to fill clipboard and pass data to Rhino, basically the other way around so I can test both

Thanks
Gerry

Hi @gerryark,

I’ve added a “Copy” command sample to the file I referenced above.

– Dale

thanks Dale
tested and it works fine

gerry