Export only visible layers from block instances

I have a project with hundreds of unique blocks, each of which has components on 5 layers. How would I go about exporting the block instances, but excluding objects from certain layers (for example exporting only from visible layers) in python?

relatively new to python.
Any help is appreciated, Cheers!

You want to retain the blocks but delete certain layers? I’m not a fluent in Python but can show a Grasshopper way if you want.

If you know a way of doing this in grasshopper I would love to hear it.

See if this works for you. Requires Elefront

BlockUpdating-Elefront.gh (19.9 KB)

This was super helpful, thank you! cheers