I have several objects containing multiple separate straight edges. These edges are on the same plane, and are placed one after another. When separating these into individual objects I would like the number suffix for the individual objects names to mirror the order they are in from one direction to another (left to right). When separating the number given by blender currently does not correspond to location on the axis. How could I rearrange object names according to location without having to rename each object manually?
1 Answer
$\begingroup$
$\endgroup$
1
Tab Enter Edit Mode, A select all, Mesh > Sort Elements > View X Axis, select vertices to be sorted, separate.
Or in Python console:
>>> for i, o in enumerate(sorted(C.selected_objects, key=lambda o: o.location.x)):
... o.name = str(i)
Or in Python text block:
import bpy
from bpy import context as C
for i, o in enumerate(sorted(C.selected_objects, key=lambda o: o.location.x)):
o.name = str(i)
-
$\begingroup$ Thank you Markus, just what I was looking for! $\endgroup$– HCSCommented Dec 6, 2021 at 16:14