import bpy,os,math sc=bpy.context.scene folder=os.path.dirname(bpy.data.filepath) bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'snow_before_cleanup.blend'),copy=True) def gate(o): x,y,z=o.matrix_world.translation if z>6:return False for i in range(10): t=i*math.tau/10 u=x*math.cos(t)+y*math.sin(t);v=-x*math.sin(t)+y*math.cos(t) if abs(u)<4.35 and 94.85.8 or o.hide_render or gate(o):remove.add(o) c=bpy.data.collections.get('Snow_Draped_Reference') if c: for o in c.objects: if gate(o):remove.add(o) count=len(remove) for o in remove:bpy.data.objects.remove(o,do_unlink=True) remaining=[o.name for o in sc.objects if o.type=='MESH' and o.name.startswith('Snow_') and gate(o)] assert not remaining,remaining bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_terrain_snow_cleaned.blend')) print('Removed',count,'remaining gate snow',len(remaining))