Pass RhinoDoc to Grasshopper in a C# Plugin hosted by Rhino.Compute

Could another option be to import the 3dm file to Grasshopper directly using Resthopper?

I would do something like this from a GH component executed in a rhino compute context (inspired from @fraguada’s earlier post):

string tmpPath = "<path to file>"
using( var doc = Rhino.RhinoDoc.CreateHeadless(null)){
  doc.Import(tmpPath);
  var ros = doc.Objects.FindByObjectType(Rhino.DocObjects.ObjectType.Mesh);
  var meshes = new List<Rhino.Geometry.Mesh>();
  foreach( Rhino.DocObjects.RhinoObject obj in ros )
  {
    meshes.Add(obj.DuplicateGeometry() as Rhino.Geometry.Mesh);
  }
}
//output the meshes or whatever from the component

Then you pass these meshes out to the GH defintion where it’s processed further. Finally you create a new modified version of the 3dm file using the File3dm class which then is streamed back to the client.