UV: bpy_extras.mesh_utils.mesh_linked_uv_islands raises error in edit mode

Maniphest Tasks: T86484

Differential Revision: https://developer.blender.org/D15778
This commit is contained in:
Chris Blackbourn 2022-08-27 16:01:56 +12:00
parent f7027f2253
commit 3cba80039d
Notes: blender-bot 2023-02-14 06:47:29 +01:00
Referenced by issue #86484, PYTHON: bpy_extras.mesh_utils.mesh_linked_uv_islands Creates Exception in EditMode
1 changed files with 11 additions and 3 deletions

View File

@ -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 = {}