Refresh selected block

possible? (without going into block manager which is slow because of a lot of blocks)

Hi Ryan - if you are willing to refresh all blocks, use

! _-BlockManager _Update _All _Enter

-Pascal

No way. I guess we need a _Selected option

Try this Python:

import rhinoscriptsyntax as rs

  def UpdateSelected():
      insts = rs.GetObjects("Select block instnces to refresh.", 4096, preselect=True)
    
    if  insts:
    
    names  = [rs.BlockInstanceName(inst)for inst in insts]
    pass
    for name in list(set(names)):
        if not rs.IsBlockEmbedded(name):
            rs.Command("-BlockManager Update " + chr(34) +name+ chr(34) + " Enter")
  UpdateSelected()

-Pascal

1 Like

It’s complaining about indentation. I messed with them a bit to try and make it look like yours but no joy.

I obviously have no idea what I am doing here

UpdateSelected.py (471 Bytes)

Try the attached - it looks like the formatting got hosed.

-Pascal

Winner. Thanks Pascal.

Thanks so much for this script, Pascal. I just managed to alter it to change the linked file for a block - saves me 5 clicks and going an extra 2 dialogs deep into the BlockManager and back out. I update linked blocks (to another file in same folder) many times a day - really wish I knew this was something scriptable a long time ago!

I guess with this script I personally don’t need it nearly as much, but how is V6 progress looking on a new and improved non-modal BlockManager?

Thank you again, Pascal, and to @wynott for bringing this up!

1 Like

Hi Pascal,

you non-python version was great too, I used it the last years.

Micha

_-RunScript (
Option Explicit
’Script written by Pascal
’ RMA
’Script version Wednesday, March 14, 2012

Call UpdateSelectedBlocks()
Sub UpdateSelectedBlocks()

Dim aObj: aObj = Rhino.GetObjects(“Select blocks to update.”, 4096, True)
If Not isArray(aObj) Then Exit Sub

Dim sBlock, aUpdate(), n
n = 0

For Each sBlock In aObj
ReDim Preserve aUpdate(n)
aUpdate(n) = Rhino.BlockInstanceName(sBlock)
n = n + 1
Next
Dim aFinal: aFinal = Rhino.CullDuplicateStrings(aUpdate)

Dim str
str = “”

Rhino.EnableRedraw False
Dim X
For Each sBlock In aFinal
X = Rhino.BlockInstanceName(sBlock)
str = str & " _Update " & chr(34) & sBlock & chr(34)
Next

str = “_-BlockManager” & str & " _Enter _Enter"

Rhino.Command str, False

Rhino.EnableRedraw True
End Sub
)

-BlockManager command options seem to have changed n Rhino 8. Update option is no longer available. Do you know by any chance if there is any other to accomplish this (update only the selected block) from a command/script? Block definitions panel keep crashing in Rhino 8 rn.

image

EDIT: I found a workaround: How to update block definition of a selected object?

Perhaps it would be worth updating it on this page, as well (UpdateSelectedBlocks.rvb)? Pascal Golay's Scripted Utilities for Rhino [McNeel Wiki]