Skip to content

Add "Select in Renaming Order" modal operator #249

Description

@Weisl

Summary

Add a modal operator that lets users explicitly define the numbering order for batch-renaming by clicking objects one by one.

Motivation

The previous "Sort by Selection" feature (removed in #248) tracked selection order automatically via a depsgraph handler. That approach was rejected by the Blender extension platform for performance and stability reasons. This operator replaces it with an explicit, user-driven workflow.

The underlying need remains: bpy.context.selected_objects does not preserve selection order, and axis-based sorting (X/Y/Z) does not cover all cases — for example a curved spine chain where anatomical order does not align with any world axis.

Proposed workflow

  1. User enables Sort in the renaming panel and selects "Selection" as the sort mode
  2. A "Select in Renaming Order" button appears
  3. User clicks the button to activate the modal
  4. Viewport header shows: "Click objects in order (N selected) — Enter to confirm, Esc to cancel"
  5. User clicks objects one by one in the desired numbering order; each clicked object is selected and assigned an internal order index
  6. User confirms with Enter (or cancels with Esc/Right-click)
  7. User runs the rename/numerate operator — objects are numbered in the clicked order

Implementation notes

  • Modal operator class OBJECT_OT_select_in_renaming_order
  • Use bpy_extras.view3d_utils + scene.ray_cast() to identify the object under the cursor
  • Consume LEFTMOUSE events to prevent Blender's own selection from interfering
  • Pass all other events through so viewport navigation (orbit, pan, zoom) keeps working
  • Store order as a selection_order custom property on each object (same storage as the old feature)
  • Cancel clears all assigned order properties and deselects objects
  • Bones: similar modal in Pose mode is a follow-up scope item (see also Rename in Order Bones #115, Bones get renamed out of order #239)

Platform confirmation needed

The platform reviewer was informed of this plan and asked whether a modal operator approach would be acceptable. This ticket should be started once that is confirmed.

Related: #248, #115, #239

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions