2023-02-01 13:43:23 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Copyright (C) 2023 Ilia Kurochkin <brothermechanic@gmail.com>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2023-06-24 13:54:49 +00:00
|
|
|
__version__ = '0.1'
|
2023-02-01 13:43:23 +00:00
|
|
|
|
|
|
|
import logging
|
|
|
|
import bpy
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
|
|
|
|
|
|
|
|
def remove_collections(collection_name=None):
|
2023-06-24 13:54:49 +00:00
|
|
|
'''Removes all all collection or collection_name only'''
|
2023-02-01 13:43:23 +00:00
|
|
|
if collection_name:
|
|
|
|
collection = bpy.data.collections.get(collection_name)
|
|
|
|
try:
|
|
|
|
for obj in collection.objects:
|
|
|
|
bpy.data.objects.remove(obj, do_unlink=True)
|
|
|
|
bpy.data.collections.remove(collection)
|
|
|
|
except Exception:
|
|
|
|
logger.info(f'There is no collection {collection_name!r} in scene')
|
|
|
|
else:
|
|
|
|
for collection in bpy.data.collections:
|
|
|
|
for obj in collection.objects:
|
|
|
|
bpy.data.objects.remove(obj, do_unlink=True)
|
|
|
|
bpy.data.collections.remove(collection)
|