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âŚ
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)
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 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.
BUT
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()?
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[2]; parms1[0] = hld_params; parms1[1] = false;
hld_params = ComputeServer.Post<dynamic>("rhino/geometry/hiddenlinedrawingparameters/setincludetangentedges", parms1);
var parms2 = new object[2];parms2[0] = hld_params;
parms2[1] = 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: