Site Tools

What is const?

Functions, function parameters, and variables in C++ can be marked with a const keyword which means that you can't change the item that is marked with a const. Just type C++ const into google to get a full explanation of what this is used for.

The Rhino.NET SDK is a wrapper around the standard Rhino C++ SDK. In order to match the C++ sdk as close as possible, all of the SDK classes were broken into interfaces and class implementations. You will notice that for every MRhino… or On… class there is a matching IRhino… or IOn… interface. The Rhino.NET interfaces are actually the functions and properties available to the const version of the wrapped C++ class while the Rhino.NET class that implements the interface is the non-const version of the C++ class.

Why do I get RMA.ConstException when debugging my plug-in?

Due to the way that Rhino.NET is wrapped, you should never try to just upcast your interface to the Rhino.NET implementing class. The only reason you are doing this is typically to get access to the non-const properties or functions of the class. Rhino.NET will recognize that you are trying to perform some non-const operation on a wrapped class that was intended to be const and throws a RMA.ConstException to tell you that this is a no no.

The proper way to get a non-const class from a const interface is to create a new non-const copy of the const class. Most classes have a constructor which takes the const interface for that class.

developer/dotnetconstobjects.txt · Last modified: 2015/09/14 (external edit)