I’m trying to Stream Geometry Objects from Rhino to another Program using NamedPipeline and Binaryformatter.
The send side of the stream seems to work, i can stream RhinoGeometry,Brep or Mesh, from one Rhino Instanze to another, but Deserialization outside of Rhino Environment won’t work proberly.
What I need is continously updated NurbsGeometry for interaktiv display purposes.
What works is streaming all RhinoGeometry Objects that are structures like Point3d, Line, Circle.
Here is some Code:
using (NamedPipeClientStream pipeClient =
new NamedPipeClientStream(".", "testpipe", PipeDirection.In))
{
pipeClient.Connect();
using (StreamReader sr = new StreamReader(pipeClient))
{
Object inf;
BinaryFormatter bf = new BinaryFormatter();
try
{
inf = bf.Deserialize(pipeClient);
Console.WriteLine("Received from server: {0}", inf.GetType().ToString());
if(inf.GetType()==new Punkt().GetType())
{
Punkt pt = (inf as Punkt);
Console.WriteLine("x: {0} y: {1} z: {2}", pt.X, pt.Y, pt.Z);
}
}
catch (IOException e)
{
Console.WriteLine("ERROR: {0}", e.Message);
}
}
pipeClient.Close();
}
The Error I get : "System.Reflection.TargetInvocationException"
from what I understand is it an missing module, I used dependencyWalker finding the missin dlls
when I add every missing dll, I get an Crash whithout Errormessage
Using a BinaryFormatter object on most of the RhinoCommon classes isn’t going to work. This is because most RhinoCommon classes are not pure .NET classes. Rather, they are really just wrappers around C++ classes exposed in our C++ SDK. Thus, the only real piece of data on most RhinoCommon classes is an IntPtr (pointer) back to some real C++ object.
Perhaps you can provide is with more details on what you are trying to do and why. With more information, we might be able to provide a better solution.
I actually think this does work Dale. The geometry classes are set up as ISerializable and are streamed a binary data using opennurbs file IO code.
Yoshy, you can’t just copy DLLs out of Rhino for your external application. For the external application, you should use the Rhino3dmIo library which can be found on nuget.
I’ve tryed the Rhino3dmIO lib, was no help at all…
For further explanation I’m trying to build an external displayprogram on openGL base.
it should be external for full use of the PC’s capabilitys.(GPU Tesselation)
The plan is to use Rhino Grashopper for generating/modifying geometry and an external program for display (with realtime rendering) and interaktion with the geometry
So I need all my geometry or at least the NURBS Information, constantly updated outside of Rhino.
if ther is a way of getting the data in C++ or more prefered C# I would love to hear about.
The Bineryformatter from Microsoft (System.Runtime.Serialization.Formatters.Binary)
I guess it calls the nessesary streaming constructor on every Object.
just to clarify, the way of data transport is irrelevant, I just need the NURBS Information to feed OpenGL
I guess I didn’t phrase my question correctly. Are you using Rhino3dmIo in your stand alone application? This has to be a reference so proper deserialization can be performed.
After working on the OpenGL side of this Project I decidet to write and stream custom strukturs that provide only the data i need to feed the renderer.
That way I save a lot of datatraffic, only Streaming raw Nurbs data
(degree, knotslist, Controlpointcoordinates)