Skip to content

Rename by X - Complete Documentation

PLACE IMAGE OF THE SIDEBAR PANEL WITH THE "Rename by X" OPTION IN FOCUS HERE

The "Rename by X" tool in DAMTools allows sequentially renaming selected objects, ordering them by their position on the X axis. It's ideal for organizing imported models, assembly parts, or any collection of objects that requires an ordered and consistent name.


Index


What is Rename by X?

It allows renaming all selected objects as BaseName_#, where # is a sequential number assigned according to each object's X position. The base name is configurable by the user.

PLACE IMAGE OF OBJECTS BEFORE AND AFTER RENAMING BY X HERE


Workflow

  1. Select the objects to rename.
  2. Activate the "Rename by X" operator from the sidebar panel or pie menu.
  3. Enter the base name in the pop-up dialog.
  4. The objects are sequentially renamed according to their X position.

PLACE GIF OR IMAGE SEQUENCE OF THE RENAMING WORKFLOW HERE


Shortcuts and Access

  • DAMTools Sidebar Panel: "Rename by X" option.
  • DAMTools Pie Menu (Shift+W): "Rename by X" option.
  • Operator: object.batch_rename_spatial

Functionality Explanation

Ordering by X Position

  • Selected objects are ordered by their X coordinate before renaming.
  • Provides a logical and visual order in the scene.

Base Name Dialog

  • Upon activating the tool, a dialog appears to enter the base name.
  • The base name will be used as a prefix for all objects.

Sequential Renaming

  • Objects are renamed as BaseName_1, BaseName_2, ...
  • Numbering is handled automatically, and errors are reported if a name cannot be assigned.

Key Code Snippets

Ordering and Renaming Objects

def execute(self, context):
    # ...
    objects_to_rename = [o for o in selected_objects if hasattr(o, 'location')]
    objects_to_rename.sort(key=lambda obj: obj.location.x)
    for i, obj in enumerate(objects_to_rename):
        new_name = f"{base_name}{i + 1}"
        obj.name = new_name

Suggested Images

  • PLACE IMAGE OF THE SIDEBAR PANEL WITH THE OPTION IN FOCUS
  • PLACE GIF OF THE RENAME BY X WORKFLOW
  • PLACE IMAGE OF OBJECTS BEFORE AND AFTER USING THE TOOL
  • PLACE IMAGE OF THE DAMTools PIE MENU WITH "Rename by X" IN FOCUS

---\n

For technical details and explanation of each file, see the technical documentation in the [DOCUMENTATION] folder.