1
$\begingroup$

I'm trying to access faces assigned to face maps groups. However, I couldn't find any relevant example of how to do it.

I need to get information about the face included in a certain face map. Is it possible to reach such information?

$\endgroup$
1
  • $\begingroup$ Welcome to BSE. I will answer this question. Wait a minute. $\endgroup$
    – tetii
    Nov 19, 2022 at 6:54

1 Answer 1

0
$\begingroup$

You can get an array of map indices with the following code.

>>> [m_face_map.value for m_face_map in obj.data.face_maps.active.data]
[0, 1, 0, 1, 0, 2, 1, 2, 0, 0, 0, 1, 0, 0, 0, 0, 2, 1, 1, 1, 0, 0, 0, 0]

However, it must be in object mode. In edit mode you get an empty array.

import bpy

# Important to run in object mode
bpy.ops.object.mode_set()

obj = bpy.context.object

# bpy_prop_collection of FaceMap
face_maps = obj.face_maps

# bpy_prop_collection of MeshFaceMap
mesh_face_maps = obj.data.face_maps.active.data


for i, mesh_face_map in enumerate(mesh_face_maps):
    if i >= 8:
        break
    print(f"faces[{i}]: {face_maps[mesh_face_map.value].name}")


""" OUTPUT
faces[0]: FaceMap
faces[1]: FaceMap.001
faces[2]: FaceMap
faces[3]: FaceMap.001
faces[4]: FaceMap
faces[5]: FaceMap.002
faces[6]: FaceMap.001
faces[7]: FaceMap.002
"""
$\endgroup$

You must log in to answer this question.

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