Zen Sets API

We offer to use our API for addon creators and other users to highlight differents parts of Mesh elements (verts, edges, faces) or UV loops

ZenSets/API/example_create_groups.py

api_example

Source Code
import bpy
import bmesh


class DemoNames:
group_even = 'Example - Even'
group_odd = 'Example - Odd'


def api_demo_create_groups():

C = bpy.context

if C.mode != 'OBJECT':
    bpy.ops.object.mode_set(mode='OBJECT')

bpy.ops.mesh.primitive_cube_add(enter_editmode=True, location=(-4, 0, 0))

p_obj = C.active_object

p_scene = C.scene
# set 'Face Parts' mode
p_scene.zen_sets_active_mode = 'face_u'

# create 1 group with object even faces (0, 2, 4 ...)
bm = bmesh.from_edit_mesh(p_obj.data)
for face in bm.faces:
    face.select_set(face.index % 2 == 0)

bpy.ops.zsts.assign_to_group(
    group_name=DemoNames.group_even, group_color=(1, 0, 0))

# create 2 group with object odd faces (1, 3, 5 ...)
bm = bmesh.from_edit_mesh(p_obj.data)
for face in bm.faces:
    face.select_set(face.index % 2 != 0)

bpy.ops.zsts.assign_to_group(
    group_name=DemoNames.group_odd, group_color=(0, 0, 1))


# DEMO
api_demo_create_groups()

Scene Properties

enum bpy.types.Scene.zen_sets_active_mode
  • vert - Vertex Sets
  • vert_u - Vertex Parts
  • edge - Edge Sets
  • edge_u - Edge Parts
  • face - Face Sets
  • face_u - Face Parts

    Type: enum in {vert, vert_u, edge, edge_u, face, face_u}

Operators

bpy.ops. zsts.assign_to_group ( identifier="", group_name="", group_color=(0, 0, 0), group_indices=[], group_mode='SELECTED' )

Assign Mesh Elements (Verts, Edges, Faces) to Group, deleting any existing assignments

Parameters:

  • identifier (str, (optional)) - Unique identifier of the Group.
  • group_name (str, (optional)) - Group Name.
  • group_color (Color, (optional)) - Group Color.
  • group_indices (Collection, (optional)) - Collection of Group Indices.
  • group_mode (enum in {‘SELECTED’, ‘INDICES’}, (optional)) - Assign Group Mode.
import bpy
# create 1 group with object even faces (0, 2, 4 ...)
bpy.ops.zsts.assign_to_group(
    group_mode='INDICES',
    group_indices=tuple(
        {'item': face.index, 'name': p_obj.name}
        for face in bm.faces if face.index % 2 == 0),
    group_name='Example - Even', group_color=(1, 0, 0))