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().ActiveViewport;
THIS WORKS FINE AND I CAN READ ALL VIEWS AND LAYOUTS
var openHeadLessDoc = RhinoDoc.OpenHeadless(@"C:\Sample.3dm");
var layout2 = openHeadLessDoc.Views.ToList().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.
Basic Sample .3dm file to read layout info.
See the difference when using RhinoDoc.Open and RhinoDoc.OpenHeadless.
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?
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?
Thank you for all the responses and the links provided.
What I am trying to do here is
- Open .3dm file using headless mode (you already mentioned that it’s not possible)
- you mentioned that "
doc.OpenHeadless doesn’t have any Layout info available in my experience". and told to use “Rhino.FileIO.File3dm.Read()”. Where I am able to get all layouts.
- I am working on RhinoDoc and I need to print it to PDF at the end.
- Is there a way I can add layouts to RhinoDoc which I am able to read using File3dm.Read()?
@Rama_Shashank do you need to print headlessly at the end?
Ok, we don’t want to use RhinoCommon.
Instead, use the API provided in RhinoCompute to get the desired result.
I am able to call few API, but got stuck in here
public static void Main(string args)
ComputeServer.WebAddress = "http://localhost:5000/";
File3dm doc = File3dm.Read(@"C:\SRS\02-Templates\TestGeometry.3dm");
IEnumerator<File3dmObject> ienum = doc.Objects.GetEnumerator();
var hld_params = ComputeServer.Post<dynamic>("rhino/geometry/hiddenlinedrawingparameters/new");
var parms1 = new object; parms1 = hld_params; parms1 = false;
hld_params = ComputeServer.Post<dynamic>("rhino/geometry/hiddenlinedrawingparameters/setincludetangentedges", parms1);
var parms2 = new object;parms2 = hld_params;
parms2 = doc.AllViews.FindName("Perspective").Viewport;
var t = ComputeServer.Post<dynamic>("rhino/geometry/hiddenlinedrawingparameters/setviewport", parms2);
ERROR in the last line
[17:03:46 INF] HTTP GET /rhino/geometry/hiddenlinedrawingparameters/setviewport responded 200 in 17.6440 ms
[17:03:49 INF] Max concurrent requests = 1
[17:04:49 INF] Max concurrent requests = 0
[17:05:49 INF] Max concurrent requests = 0
CG 6001 [17:06:43 ERR] An exception occured while processing request
System.ArgumentException: Object of type ‘Rhino.Geometry.UnknownGeometry’ cannot be converted to type ‘Rhino.DocObjects.ViewportInfo’.
at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
I think the issue is that the
rhino/geometry/hiddenlinedrawingparameters/setviewport method is looking for the
ViewportInfo to be passed in as the second argument… but you’re passing in the
Viewport. I think you need to remove the
.Viewport part of your second to last line. So something like this:
parms2 = doc.AllViews.FindName("Perspective");
Sure will try this and get back.