This object cannot be modified because it is controlled by a document

Hi,

I’m automating a process that generate text files. In the second iteration I get this error

this object cannot be modified because it is controlled by a document

The function that lauch the exception is:

public static void TrasladarModelo(ref RhinoObject obj, Punto3D hasta)
{
            try
            {
               // This line launch an exception
                var xForm = Transform.Translation(hasta.X, hasta.Y, hasta.Z);
                obj.CommitChanges();
                RhinoDoc.ActiveDoc.Objects.Transform(obj, xForm, true);         
            }
            catch (Exception ex)
            {
                Log log = new Log(Utilidades.GetRutaLog(), false);
                log.LogMensaje("ComandoRhino.TrasladarModelo", ex.Message);
                throw ex;
            }

}

This function was developed by other person, and I don’t understand well the code.

But… what can be produced this error? and how solve?

I’m working with Visual Studio and RhinoCommon

1 Like

I solved the problem by making a “new” on each iteration that manages the operation

1 Like

Hello, I face the same problem as this. Can you explain how I can “new” on each iteration? Thank you very much!

Hi @liushengyu19920315,

I order to help, we are going to need some sample code, that we can run here, that replicates the issue.

Thanks,

– Dale