C# get id of object that was modified in an input list

Hello everyone,

I have a list of Rhino objects (mostly curves, but could be points or meshes as well) referenced into a custom c# component. Now, when users modify any of these curves, I want to perform an action only on the curve that has been tinkered with.

How can I get the position of this curve in the input list? The only solution, that comes to my mind, is to keep track of all referenced GUIDs and have an event listener fired once the source changes.
Any other ideas on how to approach this?

You only have two options I think. Either handle the events yourself, or compare new inputs against previous inputs to see which ones are different. Easy for points, harder for meshes and curves. It depends a bit on what sort of changes you care about. Also, at some point the comparison may take longer than just calculating a new solution…

Thanks @DavidRutten,

I ended up listening to the OnDeleteRhinoObject event, getting the GUID of the affected object and comparing it with a previously stored list of GUIDs of all my objects.

public class CurveInsideCurve : GH_Component
        private Guid modifiedObjectId; //Class variables accessible to the event listener
        private Dictionary<Guid, int> guids;

        protected override void SolveInstance(IGH_DataAccess DA)

            List<Grasshopper.Kernel.Types.IGH_GeometricGoo> geometry = new List<Grasshopper.Kernel.Types.IGH_GeometricGoo>();
            List<Curve> iCurves = new List<Curve>();

            if (!DA.GetDataList(0, iCurves)) return;
            DA.GetDataList(0, geometry);

            if (guids == null || guids.Count != iCurves.Count) //needs better checking whether the curves list has changed
                guids = new Dictionary<Guid, int>();
                for (int i = 0; i < geometry.Count; i++) //store original GUIDs
                    guids.Add(geometry[i].ReferenceID, i);
                modifiedObjectId = new Guid(); //reset previous event

            Rhino.RhinoDoc.DeleteRhinoObject += OnDeleteRhinoObject; //subscribe to event listener
            if (guids.ContainsKey(modifiedObjectId))
                AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, $"Changed object's id: {guids[modifiedObjectId]}");

        private void OnDeleteRhinoObject(object sender, Rhino.DocObjects.RhinoObjectEventArgs args) //Save the id of an object, which was modified (deleted from scene)
            modifiedObjectId = args.ObjectId;

It would be cool if we could graft the input curves, and on geometry change, have GH expire only the affected branch, rather than expiring the entire tree. Maybe this could be an idea for GH2?

The above code works fine if only one curve is modified at a time. If I select multiple curves and modify them in one shot, the event triggers for every single one of them. Is there a way to ‘group’ these events together and have the args return a list of modified objects?

    private void OnDeleteRhinoObject(object sender, Rhino.DocObjects.RhinoObjectEventArgs args) 
        modifiedObjectId = args.ObjectId;