Need a script which will rename object names based on the block they are in

Well, if you have nested blocks, at the bottom level, you will have objects in a single block which may then be nested inside other blocks. So I guess you want the object name to be that lowest-level block name and not one of the upper level blocks it’s nested inside?

–Mitch

Edit: you can try the following and see if it does what you want…

"""Renames objects inside nested blocks to the name of the first (lowest level)
block that contains them (via recursion).  Script by Mitch Heynick 28.01.15"""
import rhinoscriptsyntax as rs

def DiveIntoBlock(blk_ID):
    blk_name=rs.BlockInstanceName(blk_ID)
    objs=rs.BlockObjects(blk_name)
    for obj in objs:
        if rs.IsBlockInstance(obj):
            DiveIntoBlock(obj)
        else:
            rs.ObjectName(obj,blk_name)
    
def BlockNameToObjects():
    blks=rs.ObjectsByType(4096)
    if not blks: return
    for blk in blks:
        DiveIntoBlock(blk)
BlockNameToObjects()