Pasting a text object raises the event with text unassigned

Hi all,
I’ve found that pasting a Rhino.DocObjects.TextObject raises the AddRhinoObject without the text assigned. Build is (6.15.19164.21011, 06/13/2019)

Steps to reproduce:

  1. Subscribe to Rhino.RhinoDoc.AddRhinoObject
  2. Create a text object
  3. Cut
  4. Paste

Example:

  void OnAddRhinoObject(object sender, Rhino.DocObjects.RhinoObjectEventArgs args) {
    if (args.TheObject is Rhino.DocObjects.TextObject)
    {
      var textObj = args.TheObject as Rhino.DocObjects.TextObject;
      Rhino.RhinoApp.WriteLine("DisplayText is: " + textObj.DisplayText);

      var textEntity = textObj.Geometry as Rhino.Geometry.TextEntity;
      Rhino.RhinoApp.WriteLine("Text is: " + textEntity.Text);

      System.Threading.Tasks.Task.Factory.StartNew(() => 
      {
        System.Threading.Thread.Sleep(100);
        Rhino.RhinoApp.WriteLine("Text after a delay is: " + textEntity.Text);
      });
    }
  }

Result:

DisplayText is: 
Text is: 
Text after a delay is: asdfasdf 

Not sure if this is related: ObjectTable.Add - bug when adding TextEntity

If this is a bug, any ideas on a workaround, or to receive another hook when the text is populated?

Cheers
Cam

Hi @camnewnham,

Rather that process object additions in RhinoDoc.AddRhinoObject, just set a flag (somewhere) that something of interest happened. Then in a RhinoApp.Idle event handler, check for that flag and and proceed.

Does this help?

– Dale