1. This object cannot be modified because it is controlled by a document. (line: 0)

Im working in C# and I am trying to get the Guid of objects in block, but whenever I do I get the following error:

  1. This object cannot be modified because it is controlled by a document. (line: 0)

My codes looks something like this:

if(RhinoDocument.Objects.Find(GUID[LoopCount_Prime]).Geometry.GetType().Name == “InstanceReferenceGeometry”)
{
var I_Ref = RhinoDocument.Objects.Find(GUID[LoopCount_Prime]) as InstanceObject;
Rhino.DocObjects.RhinoObject[] BlockObjs;
BlockObjs = I_Ref.GetSubObjects();
System.Guid New_Guid = BlockObjs[0].Id;
}

Any help would be appreciated!

Thanks,
Ryan

Why? What are you trying to do?

I’m actually working in Grasshopper writing a C# component. I want to input a block name, and output the Guid of all the objects in a block. The Guid can then be used to sort whether the object is a nested block, a geometry, a hatch pattern, ect…

Does this code sample help?

https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsDumpBlockTree.cs