I’d like to be able to pass a .3dm file to Rhino.Compute, apply a Grasshopper definition to it which modifies the document, and then stream the modified document back to the caller.
-
I have a C# class which inherits Rhino.Plugins.Plugin, which is installed on a Rhino.Compute instance and exposes a custom endpoint named “Modify” using
HostUtils.RegisterComputeEndpoint
during OnLoad, which is all working fine. -
The “Modify” method takes as input the .3dm file as a base64 string, and the string path to a GH definition file. The 3dm file is written to disk as a temp file and then loaded into memory via
var rhinoDoc = RhinoDoc.CreateHeadless(tempFilePath)
. -
My first optimistic attempt was to just call
RhinoApp.RunScript($"_-GrasshopperPlayer \"{pathToGHDef}\"", false)
but my .GH file uses eleFront components for document IO, which threwNullReferenceException
. From this post on the forums (Hops and Elefront), I’m guessing my issue is that my plugin code does not provide the Grasshopper engine with a reference to the “current” RhinoDoc. I verified this by making a GH definition with a single C# script component which outputs a bool ifthis.RhinoDocument==null
. -
I then saw that
RhinoApp.RunScript
has an overload which takes auint documentSerialNumber
, so I tried passing it my loadedrhinoDoc.RuntimeSerialNumber
, which caused the same exception again.
Is there a way to invoke the grasshopper solver where you supply the RhinoDoc reference for it to operate on?