Hi everyone,
we’re currently trying to migrate our Rhino plugin written in Visual Basic from Rhino 5 to Rhino 7.
In the initialization plugin class we have the three main function for the serialization/deserialization part:
Protected Overridable Function ShouldCallWriteDocument(options As FileWriteOptions) As Boolean Protected Overridable Sub WriteDocument(doc As RhinoDoc, archive As BinaryArchiveWriter, options As FileWriteOptions) Protected Overridable Sub ReadDocument(doc As RhinoDoc, archive As BinaryArchiveReader, options As FileReadOptions)
In the old Rhino 5 plugin version, we worked with the Rhino_DotNET V4 library, so the archive was an OnBinaryArchive type. We also worked with the RMA.OpenNURBS library.
The issue arises in this part of the code:
If Not archive.WriteObject(GetFootCurvesTrimSurface(side, eTrimSurface.topExt).NurbsSurface) Then Return False
Since we’re now using the RhinoCommon counterpart, archive As BinaryArchiveWriter, the method WriteObject no longer exists. We’re trying to write an OnNurbsSurface inside an archive, but it seems that it can’t accept anything from the RMA.OpenNURBS library.
Given the considerable size of the project, we’re trying to mantain the whole solution as backwards compatible as possible. Any suggestion about being able to write inside the BinaryWriter archive the OnNurbsSurface?
Thank you! Now we can write the OnNurbsSurface inside the archive.
For the deserialization part, the archive needs to read the OnNurbsSurface back. Here’s the part of the code where the reading on the BinaryArchiveReader is performed:
Dim onobj As OnObject = New OnNurbsSurface()
If Not CBool(archive.ReadObject(onobj)) Then Return False
SetFootCurvesTrimSurface(side, eTrimSurface.topExt, OnSurface.Cast(onobj).DuplicateSurface)
onobj = New OnNurbsSurface()
If Not CBool(archive.ReadObject(onobj)) Then Return False
SetFootCurvesTrimSurface(side, eTrimSurface.topInt, OnSurface.Cast(onobj).DuplicateSurface)
onobj.Dispose()
Thanks again for your help! If you need something else, please, let me know.
Dim geometry as GeometryBase = archive.ReadGeometry()
If geometry is Nothing Then Return False
Dim surface as Surface = TryCast(geometry, Surface)
if surface is Nothing Then Return False
SetFootCurvesTrimSurface(side, eTrimSurface.topExt, Interop.ToOnSurface(surface))
geometry = archive.ReadGeometry()
If geometry is Nothing Then Return False
surface = TryCast(geometry, Surface)
if surface is Nothing Then Return False
SetFootCurvesTrimSurface(side, eTrimSurface.topInt, Interop.ToOnSurface(surface))
I would highly recommend getting away from any RhinoDotNet code at all. RhinoDocNet has been deprecated for nearly 10 years and it should be removed from Rhino at some point in a future release.