Performance problem in editing a large number of entities

My plugin has a command that updates a large number of entities in a way like this:

foreach (MyCustomBrepObjectDerived obj in myObjectsCollection)
  Brep new_brep = MakeMyBrepChanges();
  MyCustomBrepObjectDerived new_obj = new MyCustomBrepObjectDerived(new_brep);
  doc.Objects.Replace(new ObjRef(obj.Id), new_obj);

The problem is that this operation is very slow and takes very much of the time.

Is there a way to speed up the database changes? In AutoCAD, there is the Transaction class that manages the database changes in a single session. Is there a similar thing also in Rhino?

Thanks in advance

Hi @g.todeschini,

Slow compared to what? How may objects are you replacing? How can we see how slow this really is?

No, Rhino doesn’t have a bulk, change document transaction system.

– Dale