[RhinoCommon] How to use ViewInfo when writing 3DM file from scratch


I’m working on writing 3dm files from scratch using the File3dm class. I can add geometry to the file and write it without problems. When I open the file, however, I find that the views do not show the geometry because their camera’s (I guess) are not oriented correctly.

I found that I can do

File3dm f = new File3dm();

// add geometry
double angle = Math.PI/6;
BoundingBox boundingBox; // defined from the geometry

foreach(ViewInfo vi in f.Views)
    vi.Extents(angle, boundingbox)

But, when debugging this it appears that the Views table is empty. Well, no problem, I’ll add some views to it, for instance by copying from the current RhinoDoc.

This is where I run into problems though.

  1. The RhinoDoc does not seem to use ViewInfo anywhere that is useful (only in NamedViews which is empty in the RhinoDoc)
  2. I can’t instantiate ViewInfo because the constructor is not publicly accessible.

Any help on understanding the use of ViewInfo is highly appreciated. The final goal is to write a 3dm file from scratch and have the views correctly display the content upon opening.

@Alain, can you help here?

Sure, let me do a bit of research

Hi @menno,

I just had a quick look and I don’t see how to do this. I will investigate but I’m wondering … is there a reason you can’t start with an empty template .3dm file?


1 Like

Hi @Alain,

Thanks for looking into this and your quick response. I will try your suggestion tomorrow, it had not occurred to me that I could start with a template. Tomorrow I will try if opening a template file (maybe have it as a resource in my .NET project), write the geometry into that, followed by the view manipulation as outlined above will work.


I don’t see a way to create a ViewInfo object…

Using a template file that is a resource in my .NET assembly works like a charm. Thanks!