2025-07-01
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
"""
|
||||
Copyright (C) 2019 Remington Creative
|
||||
|
||||
This file is part of Atomic Data Manager.
|
||||
|
||||
Atomic Data Manager 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.
|
||||
|
||||
Atomic Data Manager 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with Atomic Data Manager. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
---
|
||||
|
||||
This file contains functions for cleaning out specific data categories.
|
||||
|
||||
"""
|
||||
|
||||
import bpy
|
||||
from atomic_data_manager.stats import unused
|
||||
|
||||
|
||||
def collections():
|
||||
# removes all unused collections from the project
|
||||
for collection_key in unused.collections_deep():
|
||||
bpy.data.collections.remove(bpy.data.collections[collection_key])
|
||||
|
||||
|
||||
def images():
|
||||
# removes all unused images from the project
|
||||
for image_key in unused.images_deep():
|
||||
bpy.data.images.remove(bpy.data.images[image_key])
|
||||
|
||||
|
||||
def lights():
|
||||
# removes all unused lights from the project
|
||||
for light_key in unused.lights_deep():
|
||||
bpy.data.lights.remove(bpy.data.lights[light_key])
|
||||
|
||||
|
||||
def materials():
|
||||
# removes all unused materials from the project
|
||||
for light_key in unused.materials_deep():
|
||||
bpy.data.materials.remove(bpy.data.materials[light_key])
|
||||
|
||||
|
||||
def node_groups():
|
||||
# removes all unused node groups from the project
|
||||
for node_group_key in unused.node_groups_deep():
|
||||
bpy.data.node_groups.remove(bpy.data.node_groups[node_group_key])
|
||||
|
||||
|
||||
def particles():
|
||||
# removes all unused particle systems from the project
|
||||
for particle_key in unused.particles_deep():
|
||||
bpy.data.particles.remove(bpy.data.particles[particle_key])
|
||||
|
||||
|
||||
def textures():
|
||||
# removes all unused textures from the project
|
||||
for texture_key in unused.textures_deep():
|
||||
bpy.data.textures.remove(bpy.data.textures[texture_key])
|
||||
|
||||
|
||||
def worlds():
|
||||
# removes all unused worlds from the project
|
||||
for world_key in unused.worlds():
|
||||
bpy.data.worlds.remove(bpy.data.worlds[world_key])
|
||||
@@ -0,0 +1,71 @@
|
||||
"""
|
||||
Copyright (C) 2019 Remington Creative
|
||||
|
||||
This file is part of Atomic Data Manager.
|
||||
|
||||
Atomic Data Manager 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.
|
||||
|
||||
Atomic Data Manager 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with Atomic Data Manager. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
---
|
||||
|
||||
This file contains functions for deleting individual data-blocks from
|
||||
Atomic's inspection inteface.
|
||||
|
||||
"""
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def delete_datablock(data, key):
|
||||
# deletes a specific data-block from a set of data
|
||||
data.remove(data[key])
|
||||
|
||||
|
||||
def collection(key):
|
||||
# removes a specific collection
|
||||
delete_datablock(bpy.data.collections, key)
|
||||
|
||||
|
||||
def image(key):
|
||||
# removes a specific image
|
||||
delete_datablock(bpy.data.images, key)
|
||||
|
||||
|
||||
def light(key):
|
||||
# removes a specific light
|
||||
delete_datablock(bpy.data.lights, key)
|
||||
|
||||
|
||||
def material(key):
|
||||
# removes a specific material
|
||||
delete_datablock(bpy.data.materials, key)
|
||||
|
||||
|
||||
def node_group(key):
|
||||
# removes a specific node group
|
||||
delete_datablock(bpy.data.node_groups, key)
|
||||
|
||||
|
||||
def particle(key):
|
||||
# removes a specific particle system
|
||||
delete_datablock(bpy.data.particles, key)
|
||||
|
||||
|
||||
def texture(key):
|
||||
# removes a specific texture
|
||||
delete_datablock(bpy.data.textures, key)
|
||||
|
||||
|
||||
def world(key):
|
||||
# removes a specific world
|
||||
delete_datablock(bpy.data.worlds, key)
|
||||
@@ -0,0 +1,77 @@
|
||||
"""
|
||||
Copyright (C) 2019 Remington Creative
|
||||
|
||||
This file is part of Atomic Data Manager.
|
||||
|
||||
Atomic Data Manager 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.
|
||||
|
||||
Atomic Data Manager 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with Atomic Data Manager. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
---
|
||||
|
||||
This file contains functions for duplicating data-blocks from Atomic's
|
||||
inspection interface.
|
||||
|
||||
"""
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def duplicate_data(data, key):
|
||||
# creates a copy of the specified data-block and returns its key
|
||||
return data[key].copy().name
|
||||
|
||||
|
||||
def collection(key):
|
||||
# creates of copy of the specified collection and places it under the
|
||||
# scene collection
|
||||
collections = bpy.data.collections
|
||||
scene_collection = bpy.context.scene.collection
|
||||
|
||||
copy_key = duplicate_data(collections, key)
|
||||
scene_collection.children.link(collections[copy_key])
|
||||
return copy_key
|
||||
|
||||
|
||||
def image(key):
|
||||
# creates of copy of the specified image
|
||||
return duplicate_data(bpy.data.images, key)
|
||||
|
||||
|
||||
def light(key):
|
||||
# creates of copy of the specified light
|
||||
return duplicate_data(bpy.data.lights, key)
|
||||
|
||||
|
||||
def material(key):
|
||||
# creates of copy of the specified material
|
||||
return duplicate_data(bpy.data.materials, key)
|
||||
|
||||
|
||||
def node_group(key):
|
||||
# creates of copy of the specified node group
|
||||
return duplicate_data(bpy.data.node_groups, key)
|
||||
|
||||
|
||||
def particle(key):
|
||||
# creates of copy of the specified particle
|
||||
return duplicate_data(bpy.data.particles, key)
|
||||
|
||||
|
||||
def texture(key):
|
||||
# creates of copy of the specified texture
|
||||
return duplicate_data(bpy.data.textures, key)
|
||||
|
||||
|
||||
def world(key):
|
||||
# creates of copy of the specified world
|
||||
return duplicate_data(bpy.data.worlds, key)
|
||||
@@ -0,0 +1,72 @@
|
||||
"""
|
||||
Copyright (C) 2019 Remington Creative
|
||||
|
||||
This file is part of Atomic Data Manager.
|
||||
|
||||
Atomic Data Manager 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.
|
||||
|
||||
Atomic Data Manager 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with Atomic Data Manager. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
---
|
||||
|
||||
This file contains functions for removing all data-blocks from specified
|
||||
data categories.
|
||||
|
||||
"""
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def nuke_data(data):
|
||||
# removes all data-blocks from the indicated set of data
|
||||
for key in data.keys():
|
||||
data.remove(data[key])
|
||||
|
||||
|
||||
def collections():
|
||||
# removes all collections from the project
|
||||
nuke_data(bpy.data.collections)
|
||||
|
||||
|
||||
def images():
|
||||
# removes all images from the project
|
||||
nuke_data(bpy.data.images)
|
||||
|
||||
|
||||
def lights():
|
||||
# removes all lights from the project
|
||||
nuke_data(bpy.data.lights)
|
||||
|
||||
|
||||
def materials():
|
||||
# removes all materials from the project
|
||||
nuke_data(bpy.data.materials)
|
||||
|
||||
|
||||
def node_groups():
|
||||
# removes all node groups from the project
|
||||
nuke_data(bpy.data.node_groups)
|
||||
|
||||
|
||||
def particles():
|
||||
# removes all particle systems from the project
|
||||
nuke_data(bpy.data.particles)
|
||||
|
||||
|
||||
def textures():
|
||||
# removes all textures from the project
|
||||
nuke_data(bpy.data.textures)
|
||||
|
||||
|
||||
def worlds():
|
||||
# removes all worlds from the project
|
||||
nuke_data(bpy.data.worlds)
|
||||
Reference in New Issue
Block a user