mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
Improved selection of data blocks to extract
This commit is contained in:
parent
44b45cdee0
commit
7f31e88acf
1 changed files with 6 additions and 50 deletions
|
|
@ -2,8 +2,7 @@ import os
|
|||
|
||||
import bpy
|
||||
|
||||
from openpype.pipeline import AVALON_CONTAINER_ID, publish
|
||||
from openpype.hosts.blender.api.workio import save_file
|
||||
from openpype.pipeline import publish
|
||||
|
||||
|
||||
class ExtractBlenderSceneRaw(publish.Extractor):
|
||||
|
|
@ -26,55 +25,12 @@ class ExtractBlenderSceneRaw(publish.Extractor):
|
|||
# We need to get all the data blocks for all the blender objects.
|
||||
# The following set will contain all the data blocks from version
|
||||
# 2.93 of Blender.
|
||||
data_blocks = {
|
||||
*bpy.data.actions,
|
||||
*bpy.data.armatures,
|
||||
*bpy.data.brushes,
|
||||
*bpy.data.cache_files,
|
||||
*bpy.data.cameras,
|
||||
*bpy.data.collections,
|
||||
*bpy.data.curves,
|
||||
*bpy.data.fonts,
|
||||
*bpy.data.grease_pencils,
|
||||
*bpy.data.images,
|
||||
*bpy.data.lattices,
|
||||
*bpy.data.libraries,
|
||||
*bpy.data.lightprobes,
|
||||
*bpy.data.lights,
|
||||
*bpy.data.linestyles,
|
||||
*bpy.data.masks,
|
||||
*bpy.data.materials,
|
||||
*bpy.data.metaballs,
|
||||
*bpy.data.meshes,
|
||||
*bpy.data.movieclips,
|
||||
*bpy.data.node_groups,
|
||||
*bpy.data.objects,
|
||||
*bpy.data.paint_curves,
|
||||
*bpy.data.palettes,
|
||||
*bpy.data.particles,
|
||||
*bpy.data.scenes,
|
||||
*bpy.data.screens,
|
||||
*bpy.data.shape_keys,
|
||||
*bpy.data.speakers,
|
||||
*bpy.data.sounds,
|
||||
*bpy.data.texts,
|
||||
*bpy.data.textures,
|
||||
*bpy.data.volumes,
|
||||
*bpy.data.worlds
|
||||
}
|
||||
data_blocks = set()
|
||||
|
||||
# Some data blocks are only available in certain versions of Blender.
|
||||
version = tuple(map(int, (bpy.app.version_string.split("."))))
|
||||
|
||||
if version >= (3, 0, 0):
|
||||
data_blocks |= {
|
||||
*bpy.data.pointclouds
|
||||
}
|
||||
|
||||
if version >= (3, 3, 0):
|
||||
data_blocks |= {
|
||||
*bpy.data.hair_curves
|
||||
}
|
||||
for attr in dir(bpy.data):
|
||||
data_block = getattr(bpy.data, attr)
|
||||
if isinstance(data_block, bpy.types.bpy_prop_collection):
|
||||
data_blocks |= {*data_block}
|
||||
|
||||
# Write the datablocks in a new blend file.
|
||||
bpy.data.libraries.write(path, data_blocks)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue