[Bf-blender-cvs] [3cba80039d5] master: UV: bpy_extras.mesh_utils.mesh_linked_uv_islands raises error in edit mode
Chris Blackbourn
noreply at git.blender.org
Sat Aug 27 06:09:32 CEST 2022
Commit: 3cba80039d5db1d2d23ff754ab427f8ed66a71f8
Author: Chris Blackbourn
Date: Sat Aug 27 16:01:56 2022 +1200
Branches: master
https://developer.blender.org/rB3cba80039d5db1d2d23ff754ab427f8ed66a71f8
UV: bpy_extras.mesh_utils.mesh_linked_uv_islands raises error in edit mode
Maniphest Tasks: T86484
Differential Revision: https://developer.blender.org/D15778
===================================================================
M release/scripts/modules/bpy_extras/mesh_utils.py
===================================================================
diff --git a/release/scripts/modules/bpy_extras/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py
index f6dc33e4f02..d593ce6a1e4 100644
--- a/release/scripts/modules/bpy_extras/mesh_utils.py
+++ b/release/scripts/modules/bpy_extras/mesh_utils.py
@@ -13,14 +13,22 @@ __all__ = (
def mesh_linked_uv_islands(mesh):
"""
- Splits the mesh into connected polygons, use this for separating cubes from
- other mesh elements within 1 mesh datablock.
+ Returns lists of polygon indices connected by UV islands.
:arg mesh: the mesh used to group with.
:type mesh: :class:`bpy.types.Mesh`
- :return: lists of lists containing polygon indices
+ :return: list of lists containing polygon indices
:rtype: list
"""
+
+ if mesh.polygons and not mesh.uv_layers.active.data:
+ # Currently, when in edit mode, UV Layer data will always be empty
+ # when accessed though RNA. This may change in the future.
+ raise ValueError(
+ "UV Layers are not currently available from python in Edit Mode. "
+ "Use bmesh and bpy_extras.bmesh_utils.bmesh_linked_uv_islands instead."
+ )
+
uv_loops = [luv.uv[:] for luv in mesh.uv_layers.active.data]
poly_loops = [poly.loop_indices for poly in mesh.polygons]
luv_hash = {}
More information about the Bf-blender-cvs
mailing list