Skip to content

Manipulation Mixin

Entity transform operations: move, rotate, scale, copy/paste, color and layer changes, arrays.

adapters.mixins.manipulation_mixin.ManipulationMixin

Mixin for entity manipulation operations.

move_entities

move_entities(
    handles: List[str], offset_x: float, offset_y: float
) -> bool

Translate entities by the given X/Y offset via COM Move().

PARAMETER DESCRIPTION
handles

List of entity handle strings to move.

TYPE: List[str]

offset_x

Displacement in the X direction (drawing units).

TYPE: float

offset_y

Displacement in the Y direction (drawing units).

TYPE: float

RETURNS DESCRIPTION
bool

True if at least one entity was moved successfully, False otherwise.

rotate_entities

rotate_entities(
    handles: List[str],
    center_x: float,
    center_y: float,
    angle: float,
) -> bool

Rotate entities around a specified centre point via COM Rotate().

PARAMETER DESCRIPTION
handles

List of entity handle strings to rotate.

TYPE: List[str]

center_x

X coordinate of the rotation centre (drawing units).

TYPE: float

center_y

Y coordinate of the rotation centre (drawing units).

TYPE: float

angle

Rotation angle in degrees (counter-clockwise positive).

TYPE: float

RETURNS DESCRIPTION
bool

True if at least one entity was rotated successfully, False otherwise.

scale_entities

scale_entities(
    handles: List[str],
    center_x: float,
    center_y: float,
    scale_factor: float,
) -> bool

Scale entities uniformly around a specified centre point via COM ScaleEntity().

PARAMETER DESCRIPTION
handles

List of entity handle strings to scale.

TYPE: List[str]

center_x

X coordinate of the scale base point (drawing units).

TYPE: float

center_y

Y coordinate of the scale base point (drawing units).

TYPE: float

scale_factor

Uniform scale factor (e.g. 2.0 doubles the size).

TYPE: float

RETURNS DESCRIPTION
bool

True if at least one entity was scaled successfully, False otherwise.

copy_entities

copy_entities(handles: List[str]) -> bool

Copy the specified entities to the CAD clipboard via the COPY SendCommand.

PARAMETER DESCRIPTION
handles

List of entity handle strings to copy.

TYPE: List[str]

RETURNS DESCRIPTION
bool

True if the copy command was issued successfully, False otherwise.

paste_entities

paste_entities(
    base_point_x: float, base_point_y: float
) -> List[str]

Paste previously copied entities from the CAD clipboard via SendCommand.

PARAMETER DESCRIPTION
base_point_x

X coordinate of the paste base point (drawing units).

TYPE: float

base_point_y

Y coordinate of the paste base point (drawing units).

TYPE: float

RETURNS DESCRIPTION
List[str]

List of new entity handle strings. Currently always returns an empty list

List[str]

because pasted entity handles cannot be reliably tracked via COM.

change_entity_color

change_entity_color(
    handles: List[str], color: str | int
) -> bool

Change the color of the specified entities via COM.

PARAMETER DESCRIPTION
handles

List of entity handle strings to recolor.

TYPE: List[str]

color

New color as a name (e.g. "red") or ACI index (1–255).

TYPE: str | int

RETURNS DESCRIPTION
bool

True if at least one entity's color was changed, False otherwise.

change_entity_layer

change_entity_layer(
    handles: List[str], layer_name: str
) -> bool

Move the specified entities to a different layer via COM.

Creates the target layer if it does not already exist.

PARAMETER DESCRIPTION
handles

List of entity handle strings to reassign.

TYPE: List[str]

layer_name

Name of the destination layer.

TYPE: str

RETURNS DESCRIPTION
bool

True if at least one entity's layer was changed, False otherwise.

create_rectangular_array

create_rectangular_array(
    handles: List[str],
    rows: int,
    columns: int,
    row_spacing: float,
    column_spacing: float,
) -> List[str]

Create a rectangular grid of copies of the specified entities.

The original entities remain at row 0, column 0. Copies are created for all other grid positions.

PARAMETER DESCRIPTION
handles

List of entity handle strings to array.

TYPE: List[str]

rows

Number of rows in the grid.

TYPE: int

columns

Number of columns in the grid.

TYPE: int

row_spacing

Distance between rows (drawing units, Y direction).

TYPE: float

column_spacing

Distance between columns (drawing units, X direction).

TYPE: float

RETURNS DESCRIPTION
List[str]

List of handle strings for the newly created copy entities.

create_polar_array

create_polar_array(
    handles: List[str],
    center_x: float,
    center_y: float,
    count: int,
    angle_to_fill: float = 360.0,
    rotate_items: bool = True,
) -> List[str]

Create a circular array of copies of the specified entities around a centre.

The original entities remain at their position (angle 0). Copies are placed at evenly-spaced angular intervals within angle_to_fill.

PARAMETER DESCRIPTION
handles

List of entity handle strings to array.

TYPE: List[str]

center_x

X coordinate of the array centre (drawing units).

TYPE: float

center_y

Y coordinate of the array centre (drawing units).

TYPE: float

count

Total number of items in the array (including the original).

TYPE: int

angle_to_fill

Total arc angle to distribute copies over (default: 360.0°).

TYPE: float DEFAULT: 360.0

rotate_items

When True, each copy is also rotated to face outward.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
List[str]

List of handle strings for the newly created copy entities.

create_path_array

create_path_array(
    handles: List[str],
    path_points: List,
    count: int,
    align_items: bool = True,
) -> List[str]

Create copies of entities distributed evenly along a polyline path.

The original entities remain at their position. Copies are interpolated along the path defined by path_points.

PARAMETER DESCRIPTION
handles

List of entity handle strings to array.

TYPE: List[str]

path_points

Ordered list of 2-D or 3-D points defining the path.

TYPE: List

count

Total number of items in the array (including the original).

TYPE: int

align_items

When True, each copy is rotated to align with the local path direction.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
List[str]

List of handle strings for the newly created copy entities.