How to change the style of annotations of several blocks with Python?


I’m working on a cleaning script.
My goal is to associate every annotation of my drawing to the “Default” style.

This is the part of the script for simple objects (not in block):

def clean_annotations(annotations):
    for i in range(0, annotations_nb):
        rs.DimensionStyle(annotations[i], "Default")


It works : dimensions, texts and leaders style become “Default”.

I want to apply the same thing inside blocks :


for i in range (0, blocks_count):
    for j in range(0, objs_block_nb):
        rs.DimensionStyle(objs_block_id[j], "Default")

This one doesn’t work and I don’t know why.

When I debug :

print objs_block_id[j]

… display the GUID (it’s good)…

print rs.DimensionStyle(objs_block_id[j])

… display the style (it’s good) but…

rs.DimensionStyle(objs_block_id[j], "Default")

doesn’ modify the style (it’s not good!).

Thank you!

Not behind a pc right now but I think you need to get into the block and pick the dimension objects in that block and change their style

Hi @David_B, you might try if below helps, tested in V6 (Windows): (1.2 KB)
SetAnnotationDimStyleInBlock.3dm (54.8 KB)

Note that this is the simplest case only, no nested blocks, no referenced blocks from other files etc.

@Alain, could you add something like above to RhinoScriptSyntax maybe ?


1 Like

Thank you @Gijs, thank you @clement!

The script works picked block by picked block.
My goal is to apply script to several blocks in the same time.

@clement, I tried to modify the script you shared but I failed.
I actually keep trying.


Hi @David_B, try this with above example 3dm: (1.4 KB)


1 Like

Thank you @clement !!! It works!

I just added two lines to create “Default style”.

import rhinoscriptsyntax as rs

There are two scripts now : “frees” every object except dimensions in blocks.
Warning : every objects in blocks goes to “0” layer (983 Bytes) “frees” dimensions in blocks. (1.5 KB)


1 Like