1
$\begingroup$

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? before separate objects having used separate objects

$\endgroup$

1 Answer 1

1
$\begingroup$

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)
$\endgroup$
1
  • $\begingroup$ Thank you Markus, just what I was looking for! $\endgroup$
    – HCS
    Dec 6, 2021 at 16:14

You must log in to answer this question.

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