CRhinoDoc::RenderToDC

Hi,

i have a small code which makes preview images of the current scene.
But in Rhino 7 it is always black. I did not find any deprecated hints nor any examples.

What am i doing wrong?

Thanks

CRhinoView* view = RhinoApp().ActiveView();
if (extentView)
	RhinoDollyExtentsSelected(view, true);

if (dib.CreateDib(width, height, 24, true))
{
	// Set these flags as you wish.
	BOOL bIgnoreHighlights = TRUE;
	BOOL bDrawTitle = FALSE;
	BOOL bDrawConstructionPlane = FALSE;
	BOOL bDrawWorldAxes = FALSE;

	CRhinoObjectIterator it(CRhinoObjectIterator::normal_objects, CRhinoObjectIterator::active_and_reference_objects);

	if (OnlySelectedObjects)
		it.EnableSelectedFilter(true);

	if (view->ActiveViewport().DisplayModeIsShaded() || alwaysShade)
		RhinoApp().ActiveDoc()->RenderToDC(it, dib, width, height, view->ActiveViewport().View(), bIgnoreHighlights, bDrawTitle, bDrawConstructionPlane, bDrawWorldAxes, FALSE);
	else
		RhinoApp().ActiveDoc()->DrawToDC(it, dib, width, height, view->ActiveViewport().View(), bIgnoreHighlights, bDrawTitle, bDrawConstructionPlane, bDrawWorldAxes);

	return true;
}
else
	return false;

Hey @dsw,

Here is the Rhino 7 of capturing a view:

cmdSampleViewCaptureToFile.cpp

– Dale

Hi @dale,
thanks for the fast reply.
I had already a look at this example, but the advantage of the CRhinoDoc::RenderToDC was the possibility to render only the selected objects, not the whole visible scene.

But i think i can rework my code and use the code in the example rhino-developer-samples/cmdSampleMeshPreviewImage.cpp at 7 · mcneel/rhino-developer-samples · GitHub to fit my needs.

Or do you know a better/easier way to render just some selected objects?

Thanks

Hi @dsw,

The preferred way is to use a display conduit, and in the SupportChannels::SC_DRAWOBJECT channel, if the object that is about to be drawn isn’t what you want, then do this:

m_pChannelAttrs->m_bDrawObject = false;

– Dale

1 Like

Hi @dale,

excellent, works like a charm. :+1:

Thanks