Open .3dm in Headless C#

Hi, This is my first project with Rhino. We are moving from RhinoCommon to RhinoCompute.
So, I am trying to open .3dm using headless move and cant read layout model info.

            bool isTemplateFound = false;
            var openDoc = RhinoDoc.Open(@"C:\Sample.3dm", out isTemplateFound);
            var layout1 = openDoc.Views.ToList()[6].ActiveViewport;

THIS WORKS FINE AND I CAN READ ALL VIEWS AND LAYOUTS

            var openHeadLessDoc = RhinoDoc.OpenHeadless(@"C:\Sample.3dm");
            var layout2 = openHeadLessDoc.Views.ToList()[6].ActiveViewport;

ALL VIEWS ARE FINE.
ALL LAYOUTS VALUES ARE SET TO DEFAULT AND NOT ACTUAL VALUES FROM MODEL.

Is there any other way to load .3dm in Headless move?
Not sure if I am missing anything. Even when I just load and save the .3dm model layouts are created with default values like width = 1000, Height = 1000, Name = ‘Page 1’ … so on…

What do you need layouts for?

I will use File3dm directly, if only basic info is required.

Can I use File3dm in C#? if yes can you share the link.

We have views where we place all objects and use layouts to place models into layouts to generate PDFs.

Views

Layouts

Basic Sample .3dm file to read layout info.
See the difference when using RhinoDoc.Open and RhinoDoc.OpenHeadless.
Sample

.3dm file

I might be using the wrong terminology above.

May be i have the same issue when opening .3dm to get RhinoPaveView to read layout properties.
[RhinoPageView on a headless document]
(RhinoPageView on a headless document)

Any help would be much appreciated.

Hey @Rama_Shashank , I’d mirror what @gankeyu said,
doc.OpenHeadless doesn’t have any Layout info available in my experience.
File3dmIO does however and you can get geometry from layout views very easily.
I use this to import layouts from external files into new projects in my plugin. Do you need a sample?

1 Like

Thank you @csykes for the response.
After I tried File3dm I was able to get details…

As I am new to RHINO, it will be great if I can have a sample project that I can refer to.

Once again, thanks in advance.

There is a sample repo here created by mcneel:

And here are 33 instances of them using File3dm in various languages;

Is this enough for you to solve your problem?