# Insert block python

**URL:** <https://discourse.mcneel.com/t/insert-block-python/19171>\
**Category:** Scripting\
**Created:** [April 20, 2015, 1:08pm UTC](https://discourse.mcneel.com/t/insert-block-python/19171 "2015-04-20T13:08:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas84](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/thomas84/32/475006_2.png) [@thomas84](https://discourse.mcneel.com/u/thomas84)\
**Post date:** [April 20, 2015, 1:08pm UTC](https://discourse.mcneel.com/t/insert-block-python/19171/1 "2015-04-20T13:08:02Z")

</div>

Hi,

I thought that rs.InsertBlock should import a block instance that is allready in the document, but when I do the following, I get the message: does not exist in InstanceDefinitionsTable

```
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

def blocks():
    rs.EnableRedraw(False)
    topfwd=rs.FindFile("topfwd.3dm")
    centerfwdps=rs.FindFile("centerfwdps.3dm")
    centerfwdsb=rs.FindFile("centerfwdsb.3dm")
    topcenterps=rs.FindFile("topcenterps.3dm")
    topcentersb=rs.FindFile("topcentersb.3dm")
    rs.Command("_-Insert File=Yes LinkMode=Embed "+topfwd+" Block 0,0,0 1.0 0.0")
    rs.Command("_-Insert File=Yes LinkMode=Embed "+centerfwdps+" Block 0,0,0 1.0 0.0")
    rs.Command("_-Insert File=Yes LinkMode=Embed "+centerfwdsb+" Block 0,0,0 1.0 0.0")
    rs.Command("_-Insert File=Yes LinkMode=Embed "+topcenterps+" Block 0,0,0 1.0 0.0")
    rs.Command("_-Insert File=Yes LinkMode=Embed "+topcentersb+" Block 0,0,0 1.0 0.0")
    arrow_blocks=rs.ObjectsByType(4096, select=False)
    rs.DeleteObjects(arrow_blocks)
    rs.EnableRedraw(True)
    
    point = [10,0,0]
    rs.InsertBlock(topfwd,point)
    
blocks()

```

ps. when I remove the line rs.DeleteObjects(arrow\_blocks) all blocks are inserted

---

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/772979_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [April 21, 2015, 12:37am UTC](https://discourse.mcneel.com/t/insert-block-python/19171/2 "2015-04-21T00:37:29Z")

</div>

Hi Thomas,

hm, i do not know what topfwd.3dm contains. Does it contain a block definition already ? My guess is that this line returns the path with filename first:

```
topfwd=rs.FindFile("topfwd.3dm")

```

If that file does not contain a named block instance already, this line below created a block from the file content using the filename (no path, no extension) as the new block name:

```
rs.Command("_-Insert File=Yes LinkMode=Embed "+topfwd+" Block 0,0,0 1.0 0.0")

```

Maybe it fails since:

```
rs.InsertBlock(topfwd,point)

```

method asks for the instance name only but your “topfwd” variable still contains the path + filename + extension ? If you print the content of topfwd before above line, is the identical instance name listed when using `_SelBlockInstanceNamed` command in Rhino ?

- 

c.
