Copy Block name to Object name

Hi,

I have an imported file that contains block instances. The objects’ name property is not filled but the blocks’ names are and I’d like to copy those to the Objects’ name field.

The following code works from the Rhino Python Editor, but doesn’t work from a Python script component in Grasshopper.

image

The odd thing is that I can print the block instances’ names, the Objects’ names and types, yet when I would apply a modification, it retrieves the following error message:
Runtime error (MissingMemberException): ‘NoneType’ object has no attribute ‘Name’

Any idea on what do I do wrong?
Attached are the rhino and grasshopper files.

blocks.3dm (39.9 KB)
blocks_py.gh (2.7 KB)

Thanks