#modify objects inside blocks import rhinoscriptsyntax as rs def modify(block_objects): # here the objects inside the block get modified breps = [] for block_object in block_objects: if rs.IsBrep(block_object): breps.append(block_object) joined_surfaces= rs.JoinSurfaces(breps, delete_input=True) return (joined_surfaces) instances = rs.GetObjects ( message=None, filter=0, group=True, preselect=True, select=False, objects=None, minimum_count=1, maximum_count=0, custom_filter=None ) for instance in instances: block_name = rs.BlockInstanceName(instance) all_instances = rs.BlockInstances(block_name) block_point = rs.BlockInstanceInsertPoint(instance) newinstance = rs.CopyObject(instance) block_objects = rs.ExplodeBlockInstance (newinstance) all_instances_pt =[] for block_insance in all_instances: all_instances_pt.append(rs.BlockInstanceInsertPoint (block_insance)) rs.DeleteBlock(block_name) new_block_objects=[] # Stuff happens here: the modify function returns the new objects for blocks new_block_objects.append(modify(block_objects)) # End of stuff happening block_name = block_name+"newblock" rs.AddBlock(new_block_objects, block_point, name=block_name, delete_input=True) for instances_pt in all_instances_pt: rs.InsertBlock(block_name, instances_pt, scale=(1, 1, 1), angle_degrees=0, rotation_normal=(0, 0, 1))









