Editing block content via rhinoscript

I have a document with several annotations and block instances that contain annotations. I’ve been able to script replacing the font for all annotations via rhinoscript but I haven’t been able to recurse into the blocks to edit the text objects there.

I’ve tried using BlockObjects to enumerate the objects in a given block name but that doesn’t seem to have an impact on the actual instances of the block in my document.

Does the block need to be exploded, edited, and recreated? If so, how can I then replace each block instance of the previous block with the new block?

Hello - in RhinoCommon you have access to the instance Definition table and the ModifyGeometry() method -
https://developer.rhino3d.com/wip/api/RhinoCommon/html/Overload_Rhino_DocObjects_Tables_InstanceDefinitionTable_ModifyGeometry.htm

Does that get you anything useful?

-Pascal

Hey Pascal, thanks for looking into this for me. I’ll look into the instance definition table stuff now. Perhaps a better way to ask the question, and a way that might lead me to understand where I need to look next, is: Why doesn’t the following simple code modify the instances like I might expect them to?

Assuming a document with a few instances of a block, with the block containing a few text objects in it:

import rhinoscriptsyntax as rs

PROXIMA = "Proxima Nova"

def fix_fonts():
    """Set the font family of all text objects to "Proxima Nova"

    """
    block_names = rs.BlockNames(sort=True)
    for name in block_names:
        block_objects = rs.BlockObjects(name)
        for id in block_objects:
            if rs.IsText(id):
                print("Setting font for {}".format(id))
                rs.TextObjectFont(id, PROXIMA)

if __name__ == "__main__":
    fix_fonts()

The console output shows that it is at least trying to set the font on those objects by guid:

Setting font for cbcd1b50-b70d-4a51-a1eb-c0826b6a7f08
Setting font for a1d87cdb-5b03-4711-a151-99a56a94ffd5
Setting font for 5e78a529-52c4-445b-a001-0c08512f2a93
Setting font for f622e03e-b5ac-4fdf-9ebb-89be58419a23
Setting font for af8dd7cf-56ef-4338-9377-78e456fbe4d1
Setting font for 42981429-c47b-4bdc-b754-b3c0ea52a60d
...