Preview image from geometry


I want to draw preview images for geometry in memory, to display in some Eto UI of mine.
One method I tried - I need that anyway for export- is composing a File3dm instance in memory with my objects and using File3dm.GetPreviewImage() which sadly always returns null.

I found this thread which could work for my purposes but is in c++ which I’m not fluent in.

Is there a similar method or overload in Rhinocommon?

Thanks for any help or suggestions.

If you create your own File3dm object, you’ll need to add your own preview image using File3dm.SetPreviewImage.

That said, would a view capture be sufficient?


– Dale

Thanks for the answer dale!

I experimented with view capture for quite some time today, but I really don’t like it from a UX point of view.

Maybe I am missing something, I need to be able to do the following things with the viewcapture:

  • Create a RhinoView in memory
  • Zoom to my virtual geometry
  • Capture the view
  • Don’t have any of those steps visual to the user

The problem is the zooming part. Even with RedrawEnabled = false i get visual feedback in the Rhino viewports.

Here is a preview of what I’m working on and what functionality I need, my plugIn is the Panel docked on the left side:

I can cache the images on the form after first creating them (which is why there is no jumping after selecting the objects again in the treegrid), but I still need a nice non-invasive way of generating those images

Hi @lando.schumpich,

Are you trying to create previews of instance definitions? If so, have you see InstanceDefinition.CreatePreviewImage?

– Dale

Hi @dale,

Yes thats what I’m doing, The CreatePreviewImage code does not allow for sub-instance highlighting, which is what i want to achieve:

I think i could get there with PushViewProjection and PopViewProjection, do you know of a comprehensive example how to use them? (The example code of PopViewProjection never actually calls that function)

Hi @lando.schumpich,

The code behind InstanceDefinition.CreatePreviewImage does allow for the highlighting of a single instance definition object. It’s just not exposed in any SDK. I’ve added a YouTrack item to provide this.

– Dale

Perfect thanks dale!