World list script?

how do you list all the world set up ?

including finding the name for each world

can it be done with bpy.ops or bpy.data and how ?

thanks
happy bl

image
so yes, it can be done through data. you’d find the name for each world the same way you’d interact with any other bpy_collection.
image

that part works

now is there a link where we can find more info ?

like

how to make a given world the active one

or how to delete one ?

thanks
happy bl

most of this information is right there in the python console’s autocomplete

but there’s also the API documentation if you prefer it on a webpage

To create world:

bpy.ops.world.new()

To change world:

bpy.context.scene.world = bpy.data.worlds['World.001']

To delete world:

bpy.data.worlds.remove(bpy.data.worlds['World'])