C++ Tracking object change


I was wondering what is the best way to track any type of change the user makes on an object… If I get the CRhinoObject * and cast it to ON_Brep* I want to recast every time the user translates/transforms the object or moves control points… I would really appreciate some help with this…thanks!


Hi Milos,

You should never hold on to a pointer to a Rhino object for very long, as you never know when the pointer will become invalid and, boom, down goes Rhino.

The preferred way of tracking Rhino objects is by their object id or UUID. For example:

const CRhinoObject* rh_obj = GetSomeRhinoObject();
if (0 != rh_obj)
  ON_UUID obj_id = rh_obj->ModelObjectId();
  // TODO...

When when you need to recall the object, you just call CRhinoDoc::LookupObject().

There are a couple of way of tracking object changes. The most obvious one is to create an event watcher and look for CRhinoEventWatcher::OnReplaceObject events.

– Dale