update addons (for 5.2)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
schema_version = "1.0.0"
|
||||
id = "datablock_utils"
|
||||
version = "1.3.0"
|
||||
version = "1.3.2"
|
||||
name = "Data-Block Utilities"
|
||||
tagline = "Show users, merge duplicates, find similar, and more"
|
||||
maintainer = "Leonardo Pike-Excell <leonardopike.excell@gmail.com>"
|
||||
|
||||
@@ -49,6 +49,8 @@ def _generate_id_types() -> dict[str, IDType]:
|
||||
if bpy.app.version >= (4, 3, 0):
|
||||
if bpy.app.version >= (5, 0, 0):
|
||||
collections.remove(next(c for c in collections if c.identifier == 'annotations'))
|
||||
if bpy.app.version >= (5, 2, 0):
|
||||
collections.remove(next(c for c in collections if c.identifier == 'all_ids'))
|
||||
_assign('CURVES', 'hair_curves', enums, collections)
|
||||
if bpy.app.version >= (5, 0, 0):
|
||||
_assign('GREASEPENCIL', 'grease_pencils', enums, collections, remove=False)
|
||||
|
||||
@@ -24,6 +24,10 @@ def get_settings() -> DBU_PG_FindSimilarSettings:
|
||||
return bpy.context.scene.dbu_similar_settings # type: ignore
|
||||
|
||||
|
||||
def is_local_id(id_data: bpy.types.ID) -> bool:
|
||||
return not id_data.library and not id_data.override_library
|
||||
|
||||
|
||||
def get_invalid_nodes(ntree: NodeTree) -> set[Node]:
|
||||
settings = get_settings()
|
||||
invalid_nodes = set()
|
||||
@@ -100,6 +104,24 @@ def get_image_props(img: bpy.types.Image) -> tuple[Any, ...]:
|
||||
)
|
||||
|
||||
|
||||
def get_light_props(light: bpy.types.Light) -> tuple[Any, ...]:
|
||||
props: list[Any] = [
|
||||
tuple(light.color),
|
||||
light.energy,
|
||||
light.exposure,
|
||||
light.use_shadow,
|
||||
light.normalize,
|
||||
]
|
||||
match light.type:
|
||||
case 'AREA':
|
||||
props.extend((light.size, light.size_y, light.shape))
|
||||
case 'SPOT':
|
||||
props.extend((light.spot_size, light.spot_blend))
|
||||
case 'SUN':
|
||||
props.append(light.angle)
|
||||
return tuple(props)
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class NodeProperties:
|
||||
id_data: Node | NodeTree
|
||||
@@ -218,7 +240,7 @@ def contents_of_ntrees(
|
||||
) -> defaultdict[str, list[NodeProperties]]:
|
||||
content_map = defaultdict(list)
|
||||
for id_data in bl_data:
|
||||
if id_data.library or (not isinstance(id_data, NodeTree) and not id_data.use_nodes):
|
||||
if not is_local_id(id_data) or (not isinstance(id_data, NodeTree) and not id_data.use_nodes):
|
||||
continue
|
||||
|
||||
ntree = id_data if isinstance(id_data, NodeTree) else id_data.node_tree
|
||||
@@ -238,6 +260,9 @@ def contents_of_ntrees(
|
||||
tuple(p) if isinstance(p, bpy.types.bpy_prop_array) else p for p in props]
|
||||
contents.append(props)
|
||||
|
||||
if isinstance(id_data, bpy.types.Light) and bpy.app.version >= (5, 1, 0):
|
||||
contents.append(NodeProperties(id_data, ['LIGHT PROPS', *get_light_props(id_data)]))
|
||||
|
||||
if not isinstance(id_data, NodeTree):
|
||||
continue
|
||||
|
||||
@@ -403,7 +428,7 @@ def find_similar_and_duplicate_ntrees(id_type: str) -> None:
|
||||
|
||||
def find_duplicate_images() -> None:
|
||||
duplicates = []
|
||||
images = [i for i in bpy.data.images if not i.library]
|
||||
images = [i for i in bpy.data.images if is_local_id(i)]
|
||||
images.sort(key=get_image_props)
|
||||
for _, raw_group in groupby(images, get_image_props):
|
||||
group = [i.name for i in raw_group]
|
||||
@@ -414,7 +439,7 @@ def find_duplicate_images() -> None:
|
||||
|
||||
|
||||
def find_duplicate_meshes() -> None:
|
||||
meshes = [m for m in bpy.data.meshes if not m.library]
|
||||
meshes = [m for m in bpy.data.meshes if is_local_id(m)]
|
||||
seen = set()
|
||||
results = []
|
||||
for m1 in meshes:
|
||||
@@ -493,6 +518,8 @@ class DBU_OT_SimilarAndDuplicatesClearResults(Operator):
|
||||
def merge_ids(duplicate_ids: Iterable[Iterable[bpy.types.ID]]) -> int:
|
||||
to_remove = []
|
||||
for target, *junk in duplicate_ids:
|
||||
if not is_local_id(target) or any(not is_local_id(id_data) for id_data in junk):
|
||||
continue
|
||||
to_remove.extend(junk)
|
||||
for id_data in junk:
|
||||
id_data.user_remap(target)
|
||||
|
||||
Reference in New Issue
Block a user