0
$\begingroup$

I wrote a simple code based on this answer python: Split mesh by uv islands that should convert UV island borders to seams and then select them as edges but it worked unstably. To make uv.seams_from_islands() work

  1. UV sync selection should be enabled
  2. All faces should be selected

Is this how it should work?

$\endgroup$

1 Answer 1

1
$\begingroup$

I made the code in the connected question work successfully after adding a selection of all mesh elements and all UVs:

bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.uv.select_all(action='SELECT')

Before running bpy.ops.uv.seams_from_islands()

Here is the full modified code:

import bpy
import bmesh
context = bpy.context
obj = context.edit_object
me = obj.data
bm = bmesh.from_edit_mesh(me)
# old seams
old_seams = [e for e in bm.edges if e.seam]
# unmark
for e in old_seams:
    e.seam = False
# mark seams from uv islands
bpy.ops.mesh.select_all(action='SELECT')  # NEW LINE!!!
bpy.ops.uv.select_all(action='SELECT')   # NEW LINE!!!
bpy.ops.uv.seams_from_islands()
seams = [e for e in bm.edges if e.seam]
# split on seams
bmesh.ops.split_edges(bm, edges=seams)
# re instate old seams.. could clear new seams.
for e in old_seams:
    e.seam = True
bmesh.update_edit_mesh(me)
To obtain separate mesh objects for each newly splitter section, one can add this line at the end:

bpy.ops.mesh.separate(type='LOOSE')
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .