# Import nested Block from file

**URL:** <https://discourse.mcneel.com/t/import-nested-block-from-file/191415>\
**Category:** Rhino Developer\
**Tags:** windows\
**Created:** [September 18, 2024, 10:18am UTC](https://discourse.mcneel.com/t/import-nested-block-from-file/191415 "2024-09-18T10:18:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vahid.azizi.1992](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/vahid.azizi.1992/32/513424_2.png) [@vahid.azizi.1992](https://discourse.mcneel.com/u/vahid.azizi.1992)\
**Post date:** [September 18, 2024, 10:18am UTC](https://discourse.mcneel.com/t/import-nested-block-from-file/191415/1 "2024-09-18T10:18:55Z")

</div>

I want to import blocks from a file into the file. However, the nested blocks are not added to the `InstanceDefinitionTable`. I checked the data, and the nested blocks are imported as `InstanceReferenceGeometry`, but they are not added to the `InstanceDefinitionTable`.

```
        string filePath = string.Empty;
        if (!DA.GetData(0, ref filePath)) return;
        File3dm file3dm = File3dm.Read(filePath);
        RhinoDoc doc = RhinoDoc.ActiveDoc;
        List<string> stringGeomatry = new List<string>();
        foreach (var instanceDef in file3dm.InstanceDefinitions)
        {
            List<GeometryBase> blockList = new List<GeometryBase>();
            List<ObjectAttributes> blocattribute = new List<ObjectAttributes>();
            foreach (var obj in instanceDef.GetObjectIds())
            {
                var taype = file3dm.Objects.FindId(obj);
                blockList.Add(taype.Geometry);
                blocattribute.Add(taype.Attributes);
            }
            doc.InstanceDefinitions.Add(instanceDef.Name, instanceDef.Description, Point3d.Origin, blockList,blocattribute);
        }

```

---

<div class="post-metadata">

**Author:** ![Mahdiyar](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mahdiyar/32/472862_2.png) [@Mahdiyar](https://discourse.mcneel.com/u/Mahdiyar)\
**Post date:** [September 18, 2024, 4:06pm UTC](https://discourse.mcneel.com/t/import-nested-block-from-file/191415/2 "2024-09-18T16:06:24Z")

</div>

![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/d/5/b/d5ba3693d40400f23fc5abc9452034e43cd48f45.jpeg)

```cs
private void RunScript(string path, ref object a)
{
    var doc3dm = RhinoDoc.OpenHeadless(path);
    var geometryList = new List<IGH_GeometricGoo>();
    foreach (var rhinoObject in doc3dm.Objects.GetObjectList(Rhino.DocObjects.ObjectType.InstanceReference))
    {
        var geometry = GH_Convert.ObjRefToGeometry(new ObjRef(rhinoObject));
        if (geometry != null)
            geometryList.Add(geometry);
    }
    doc3dm.Dispose();
    a = geometryList;
}

```

[Blocks.zip](https://discourse.mcneel.com/uploads/short-url/yzWteSjVahF8eQdyjgpQhU2YTdn.zip) (35.5 KB)

---

<div class="post-metadata">

**Author:** ![scottd](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/scottd/32/494002_2.png) [@scottd](https://discourse.mcneel.com/u/scottd)\
**Post date:** [September 18, 2024, 7:19pm UTC](https://discourse.mcneel.com/t/import-nested-block-from-file/191415/3 "2024-09-18T19:19:55Z")

</div>

In rhino 8 blocks can created from imported geometry using the new data types in grasshopper.

---

<div class="post-metadata">

**Author:** ![vahid.azizi.1992](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/vahid.azizi.1992/32/513424_2.png) [@vahid.azizi.1992](https://discourse.mcneel.com/u/vahid.azizi.1992)\
**Post date:** [September 18, 2024, 7:38pm UTC](https://discourse.mcneel.com/t/import-nested-block-from-file/191415/5 "2024-09-18T19:38:43Z")

</div>

Thank you for your guidance, but I want to develop my program in Rhino version 7.I am working with files converted to binary arrays, and in my plugin, there is no access to the file path

---

<div class="post-metadata">

**Author:** ![vahid.azizi.1992](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/vahid.azizi.1992/32/513424_2.png) [@vahid.azizi.1992](https://discourse.mcneel.com/u/vahid.azizi.1992)\
**Post date:** [September 18, 2024, 7:43pm UTC](https://discourse.mcneel.com/t/import-nested-block-from-file/191415/6 "2024-09-18T19:43:01Z")

</div>

Thank you, Mahyar! My problem is with importing data into Rhino 7
