CommitChanges() returns false after first call

Anyway to get a reason for a CommitChanges() failure? First call to CommitChanges on a RhinoObject saves fine, every call afterwards returns false until another object is selected. Was working in Rhino6, and stopped after upgrading to Rhino7.

Hi @daniel19,

Can you provide a simple code example, that we can run here, that demonstrates the issue you are seeing?

– Dale

Sure here is a quick sample, slightly different from our main project but this one seems to fail on every call to CommitChanges(). We are not modifying anything on the objects outside of user keys at the moment.

Thanks
-daniel

Hi @daniel19,

From a modeless, tabbed panel, your code should look more like this:

private void SetAttributeUserText(IEnumerable<RhinoObject> rhObjects)
{
  var doc = RhinoDoc.FromRuntimeSerialNumber(m_doc_serial_number);
  if (null != doc)
  {
    var undo_sn = doc.BeginUndoRecord("Set attribute user text");
    foreach (var rhObj in rhObjects)
    {
      var attibutes = rhObj.Attributes.Duplicate();
      if (attibutes.SetUserString("TEST", "TEST"))
        doc.Objects.ModifyAttributes(rhObj.Id, attibutes, false);
    }
    if (undo_sn > 0)
      doc.EndUndoRecord(undo_sn);
  }
}

After doing this, your Objects collection will be out-of-date and need to be refreshed, so as to point to the current instance of the object.

Hope this helps.

– Dale