5
$\begingroup$

I need to split a mesh by the edges where the seam is set, to then access Mesh Island Index of a face/faces (by using Mesh Island node)

Currently I am assigning a very low value crease on the edges where seam is set, and accessing it as a "crease" property but this is more of a hack rather than a solution. enter image description here

Using vertex groups will create extra cuts on the corners.

enter image description here

Is there a way to access "seams" as edge property (boolean/float)?

or a way to set which edges to split mesh on (not verticles/vertex groups)?

or a way to get the index of UV Island of selected face(s) without using the approach described above?

$\endgroup$
1
  • 1
    $\begingroup$ Don't know if either of the new UV nodes coming in Blender 3.3 alpha are likely to expose them? This is the developer commit for them which mentions existing seam flags in the mesh geometry, but that's way outside my experience so you may have to dig there for more details. $\endgroup$
    – John Eason
    Jul 14, 2022 at 23:05

2 Answers 2

5
$\begingroup$
import bpy

def add_seam_attr(attributes):
    return attributes.new(name='seam', type='BOOLEAN', domain='EDGE')

obj = bpy.context.object

if obj.type == 'MESH':
    mesh = obj.data
    seam = mesh.attributes.get('seam')
       
    if seam:
        if seam.data_type != 'BOOLEAN' or seam.domain != 'EDGE':
            mesh.attributes.remove(seam)
            seam = add_seam_attr(mesh.attributes)
    else:
        seam = add_seam_attr(mesh.attributes)
        
    seam.data.foreach_set('value', [e.use_seam for e in mesh.edges])
    mesh.update()

This script operates on the mesh of the active object. It will create or update the attribute named seam on domain edge and of boolean data type, it's values will be the same as the use_seam flag in the edges.

enter image description here

enter image description here

Data is not updated when ran from edit mode, so it's better to change to object mode before running the script.

After creating the attribute, you will be able to use it inside Geometry Nodes:

enter image description here

$\endgroup$
1
  • 5
    $\begingroup$ Genius. Damn, we need a Python node. $\endgroup$
    – quellenform
    Jul 15, 2022 at 8:44
2
$\begingroup$

https://blender.stackexchange.com/a/269344/89484

was a great idea, so I created an add-on. This will make it easier to unwrap while checking the UVs.

enter image description here

bl_info = {
    "name": "Add Seam Attribute",
    "blender": (2, 80, 0),
    "category": "Object",
    "author": "KSYN",
    "description": "Add or update the 'seam' attribute for selected mesh objects",
    "location": "View3D > UV Mapping",
    "warning": "",
    "doc_url": "https://blender.stackexchange.com/questions/269330/how-to-get-seams-as-an-edge-property-in-geometry-nodes",
    "support": "COMMUNITY",
    "version": (1, 0, 0),
    "blenderapi": (3, 6, 0),
    "update_check": False,  
    "category": "Mesh",  
}


import bpy

class AddSeamOperator(bpy.types.Operator):
    bl_idname = "object.add_seam_operator"
    bl_label = "Add Seam Attribute"
    bl_description = "Add or update the 'seam' attribute for selected mesh objects"
    
    def execute(self, context):
        def add_seam_attr(attributes):
            return attributes.new(name='seam', type='BOOLEAN', domain='EDGE')

        bpy.ops.object.mode_set(mode='OBJECT')

        obj = bpy.context.object

        if obj.type == 'MESH':
            mesh = obj.data
            seam = mesh.attributes.get('seam')

            if seam:
                if seam.data_type != 'BOOLEAN' or seam.domain != 'EDGE':
                    mesh.attributes.remove(seam)
                    seam = add_seam_attr(mesh.attributes)
            else:
                seam = add_seam_attr(mesh.attributes)

            seam.data.foreach_set('value', [e.use_seam for e in mesh.edges])
            mesh.update()

        bpy.ops.object.mode_set(mode='EDIT')
        
        return {'FINISHED'}

def menu_func(self, context):
    self.layout.operator(AddSeamOperator.bl_idname)

def register():
    bpy.utils.register_class(AddSeamOperator)
    bpy.types.VIEW3D_MT_uv_map.append(menu_func)

def unregister():
    bpy.utils.unregister_class(AddSeamOperator)
    bpy.types.VIEW3D_MT_uv_map.remove(menu_func)

if __name__ == "__main__":
    register()

Further improved version

Completely original attributes can be added to edges, vertices and noodles.

2024-04-13 I decided to manage this in GIT for study purposes because of the long character count.

https://github.com/Hydrocallis/AddAttribute

https://github.com/Hydrocallis/AddAttribute/wiki

enter image description here

$\endgroup$

You must log in to answer this question.

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