How to create a curve class inherited from Rhino.Geometry.Curve


I would like to create my own type of curves with rhinocommon, as an inheritance class from a Rhino.Geometry.Curve instance. I want to replicate the behavior of a polyline, with an additional array of Point3d, to control several linear segments with a bunch of handles.

I don’t know how to start. From my experience in Autodesk Maya, I would ideally have a library of C# codes implementing such a class, then launch my curve in Rhino as an instance of this class (typically inherited from MPxNode or MPxSurfaceShape in Maya). In Rhino so far I’ve coded scripts to run commands over existing objects, but not a library to create objects. Could you provide a simple example of a C# library creating an object from inheritance (if from a curve, better!)?

Many thanks!

If all you are looking to do is provide custom grip editing, then you don’t need a custom curve object. You just need to implement a custom grip handler. This is done by inheriting classes from CustomGripObject, CustomObjectGrips and registering a custom grip enabler using CustomObjectGrips.RegisterGripsEnabler. All this in the Rhino.DocObjects.Custom namespace.

For a sample, see the SampleCsRectangleGrips samples on my GitHub site. This example demonstrates how to add custom grips to “rectangle” polyline so the curve remains a rectangle when custom point edited.

Hello Dale,

Thank you, it looks very interesting!
How can I build and run the solution with Mac and Xamarin? I open the .sln with Xamarin and it looks like the Rhino.UI and RhinoCommon all the other references to Rhino are not there, so the solution cannot be built.

The project was build with Visual Studio. Thus, paths to custom, referenced libraries (such as RhinoCommon.dll) point to a file in the Windows file system. On OS X, RhinoCommon is in the bundle. Thus, if you want to use the same project (vcproj) file, then you will need to re-path this reference.

A better approach is to do some reading on how to work on cross-platform projects.

Where do you see this? This isn’t part of the SampleCsRectangleGrips project…

Hi Dale,

To be sure, about converting your project into a cross-platform, in OS X should I create a blank solution with .CrossPlatform, then add as existing project the one you built with Visual Studio, and finally remove the Windows references and add the OS X ones? Would that work?
I tried to directly open your solution in Xamarin, go to References -> Edit References and look for the OS X references. But I don’t find them, in the list there’re mostly references from a Mono / NET 4.0.0 package. How can I change the references of libraries within Xamarin?

About the Rhino.UI, sorry, I was looking at the HelloRhinoCommon at that moment…

Thank you!

Hello Dale,

I built and run your SampleCsRectangleGrips project with a Windows platform Rhino license. The rectangle effectively shows the custom grips and, when dragging, it is updated on the fly.

However, I also migrated the project to Xamarin in Rhino for Mac (just copy-pasting the source codes to a blank project) and, although it keeps working, there are some functionalities that do not appear:

  1. The grips don’t show up on the rectangle. If I click on the rectangle over the place of an expected grip, I can select it though.

  2. If I drag a grip (keeping the select button), the rectangle does not update with the dragging. Once the selection is released, the new updated rectangle is finally shown.

I don’t know if these differences of the project between Windows and Mac are due to the version of Rhino, or rather to the code. Should I have made some more changes when migrating the project to Xamarin?

Many thanks!

Without digging into the core code to see the differences, I suspect this is the problem. I do know that the version of RhinoCommon are (currently) not equivalent between Windows and Mac Rhino.