Is this the best way to automatically update linked blocks?

Blockmanager isn’t very effective in updating blocks so I wrote a small script,
but does this seem like the most reliable and effective way to do so?

import rhinoscriptsyntax as rs


if blockList:
    for block in blockList:
        if status==-3:
        if status==1:
            print ("Updating "+str(block) )
            rs.Command("-BlockManager _Update "+str(block)+" _Enter")
    print "File has "+str(len(blockList) - n )+" linked blocks, "+str(nn)+" updated"

print "File has "+str(len(blockList) - n )+" linked blocks, "+str(nn)+" updated"


Well, basically to ensure the best speed and stability.
I could not find a dedicated command for it and I’m trying to avoid using Rhino.Command as much as possible, so I just wondered.

We need an effective and good way to update changed linked blocks.
Blockmanager is ineffective at doing so, and it messes with the layer structure so I don’t want to use “update all” (it doesn’t remember which layers are on and which are off) so that will be the next step for the script.

Hi Jorgen,

To avoid using a scripted command use the below code:

import rhinoscriptsyntax as rs
import scriptcontext


if block_table:
    not_linked = 0
    for block in block_table:
        status = int(block.ArchiveFileStatus)
        if status == -3:
            not_linked += 1
        if status == 1:
            updated += 1
            print ("Updating {}".format(block.Name) )
    print "File has {} linked block(s), {} updated".format(block_table.Count - not_linked ,updated)

I did not add comments, but let me know if you need clarification.



Nice, Willem, thanks as always!
I never figure out how to find what I need in scriptcontext, how do you do it?

Thanks a lot!

Hi @Willem,
working perfectly fine.
I have a question though - and I guess it has been discussed in some other topics here.

Is there away to avoid this popup asking what to do with nested blocks?
I personally would like to chose option “Replace with imported block” all the time.


Thanks in adavance…

1 Like