I have been working to build Web API with Django REST framework running Rhino Inside and other geometry libraries. The machine hosting the server would run the geometric calculations, output geometry to a new Rhino3dm file (possibly multiple geometry types). The request would be sent through UI in open Rhino instance, on user PC. I would like the new Rhino file to be passed to the user back, and ideally to import it with all its contents to an open Rhino Instance (on user side).
Now my question is what would be the best way to serialize / encode data, to pass it back to the user, and import to an open Rhino instance ? Hopefully as a file, rather that serialising/deserialising each geometry type.
Previously I successfully passed geometry (ex. Breps) from server side through: Json = Json.dumps(Newtonsoft.Json.JsonConvert.SerializeObject(Brep))
which on the user side opens as: Brep = Newtonsoft.Json.JsonConvert.DeserializeObject(Json, Rhino.Geometry.Brep)
One option would be to have your web server return the whole raw file instead of encoded data into json. If it takes a long time to generate the file, you could also return a URL to the client that the client could later call to try and retrieve the file.
Great. I’ve managed to pass URL to the client. I can download the file and save locally, but is there an easy way to directly pass the file to import to an open rhino document ? Or would I have to download file temporarily, import to ActiveDoc and delete?
@stevebaer it works fine if I save a file locally, then import it into a document and finally delete it. I was just wondering if there is a way of opening a file directly from the server location such as:
or alternatively:
But none of this work. If not, I will settle on the working version. Just curiosity, trying to avoid unnecessary steps.