Checking onAdd Event Source

Hi @dale, Is it possible to check what fires onAdd event listener with Rhinocommon? I want to check if onAdd event occurred because of “importing objects into the document” or “copying an object in the document”. Thanks!

Sure - just make a test command that listens to the “OnAdd…” event.

You can also build and run this example:

– Dale

Hi @dale , I guess I couldn’t explain the situation. I created a listener for onAdd event and both actions (importing objects to document and copying an object in the document) fires the listener. I want to know if listener fired from “importing” or “copying”. I hope it is more clear now. Thanks!

When import a file, a RhinoDoc.BeginOpenDocument event will be triggered with the DocumentOpenEventArgs.Merge property set to true. This occurs before any RhinoDoc.AddRhinoObject event.

– Dale

1 Like

Hi, Thanks a lot! Listening OpenDocument events solved the issue.

static bool isImporting = false;

internal static void onEndOpenDoc(object sender, DocumentOpenEventArgs e)
{
     isImporting = false;
}

internal static void onBeginOpenDoc(object sender, DocumentOpenEventArgs e)
{
      isImporting = e.Merge;
}