How to update/persist Rhino Object changes without saving the model?

Hi, I have objects referencing Rhino geometry objects (for example, Breps). When I change the geometry of the Rhino Breps, my objects still reference the old geometry unless I save the model and reopen it. I tried .CommitChanges() and it didn’t work. Thanks, Ming

Hi @ming.ma.usa,

Try using this pattern:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  // 1: Get the object
  var filter = ObjectType.Brep;
  var rc = RhinoGet.GetOneObject("Select Brep", false, filter, out var objref);
  if (rc != Result.Success || null == objref)
    return rc;

  // 2: Get the object's geometry
  var brep = objref.Brep();
  if (null == brep)
    return Result.Failure;

  // 3: Copy the geometry
  var brepCopy = brep.DuplicateBrep();

  // 4: Modify the geometry copy
  brepCopy.MakeValidForV2();

  // 5: Replace the original with the copy
  doc.Objects.Replace(objref, brepCopy);

  doc.Views.Redraw();

  return Result.Success;
}

– Dale

Thanks, Dale. The approach doesn’t work for flipping surface normal. Is there a method to update all objects before saving then reopening the model?