From 3cba80039d5db1d2d23ff754ab427f8ed66a71f8 Mon Sep 17 00:00:00 2001 From: Chris Blackbourn Date: Sat, 27 Aug 2022 16:01:56 +1200 Subject: UV: bpy_extras.mesh_utils.mesh_linked_uv_islands raises error in edit mode Maniphest Tasks: T86484 Differential Revision: https://developer.blender.org/D15778 --- release/scripts/modules/bpy_extras/mesh_utils.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'release') 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 = {} -- cgit v1.2.3