Last active
April 28, 2022 02:04
-
-
Save GGLinnk/744ea8f201e35d612ad907468d7de208 to your computer and use it in GitHub Desktop.
Blender Python API: Gets collections by creating them or getting them by name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
def get_collection(collection_name: str) -> bpy.types.Collection: | |
return bpy.data.collections.get(collection_name) or bpy.data.collections.new(collection_name) | |
def get_collections(collection_names: list) -> list: | |
return [get_collection(collection_name) for collection_name in collection_names] | |
if __name__ == __main__: | |
get_collection("TEST_COLLECTION") | |
get_collections(["TEST_COLLECTION", "COL1", "COL2"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment