Files
mk64/tools/blender/clean_scene.py
coco875 6da6598cc6 extract models with blender (#577)
* start making models extraction with blender

* finishing extract model

* Update fast64

* extract course

* Update fast64

* Update fast64

* simplify import of course_displaylists and course_textures and remplace adress with texture

* Update fast64

* change data format and simplify the thread queue

* move in a blender folder

* remove fast64

* re add fast64

* add model_extract and fast64_blender in makefile

* multithread with make file split the models into multiple json and add course segment

* Update fast64

* remove old model_extract

* remove the error when he don't find blender

* start rename around course section

* update submodule fast64

* fix compilation issue and add some model to extract

* Update fast64

* remove fast64

* re add fast64

* update submodule

* fix compilation issue

* add other collision gfx and prepare reorganise file

* re arrange json

* Create README.MD

* Update README.MD

* Update README.MD

* update fast64

---------

Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
2024-09-15 17:06:29 -06:00

43 lines
1.4 KiB
Python

import bpy
def purge_orphans():
if bpy.app.version >= (3, 0, 0):
bpy.ops.outliner.orphans_purge(
do_local_ids=True, do_linked_ids=True, do_recursive=True
)
else:
# call purge_orphans() recursively until there are no more orphan data blocks to purge
result = bpy.ops.outliner.orphans_purge()
if result.pop() != "CANCELLED":
purge_orphans()
def clean_scene():
"""
Removing all of the objects, collection, materials, particles,
textures, images, curves, meshes, actions, nodes, and worlds from the scene
"""
if bpy.context.active_object and bpy.context.active_object.mode == "EDIT":
bpy.ops.object.editmode_toggle()
for obj in bpy.data.objects:
obj.hide_set(False)
obj.hide_select = False
obj.hide_viewport = False
bpy.ops.object.select_all(action="SELECT")
bpy.ops.object.delete()
collection_names = [col.name for col in bpy.data.collections]
for name in collection_names:
bpy.data.collections.remove(bpy.data.collections[name])
# in the case when you modify the world shader
world_names = [world.name for world in bpy.data.worlds]
for name in world_names:
bpy.data.worlds.remove(bpy.data.worlds[name])
# create a new world data block
bpy.ops.world.new()
bpy.context.scene.world = bpy.data.worlds["World"]
purge_orphans()