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
¶
Translate entities by the given X/Y offset via COM Move().
| PARAMETER | DESCRIPTION |
|---|---|
handles
|
List of entity handle strings to move.
TYPE:
|
offset_x
|
Displacement in the X direction (drawing units).
TYPE:
|
offset_y
|
Displacement in the Y direction (drawing units).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if at least one entity was moved successfully, False otherwise. |
rotate_entities
¶
Rotate entities around a specified centre point via COM Rotate().
| PARAMETER | DESCRIPTION |
|---|---|
handles
|
List of entity handle strings to rotate.
TYPE:
|
center_x
|
X coordinate of the rotation centre (drawing units).
TYPE:
|
center_y
|
Y coordinate of the rotation centre (drawing units).
TYPE:
|
angle
|
Rotation angle in degrees (counter-clockwise positive).
TYPE:
|
| 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:
|
center_x
|
X coordinate of the scale base point (drawing units).
TYPE:
|
center_y
|
Y coordinate of the scale base point (drawing units).
TYPE:
|
scale_factor
|
Uniform scale factor (e.g. 2.0 doubles the size).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if at least one entity was scaled successfully, False otherwise. |
copy_entities
¶
Copy the specified entities to the CAD clipboard via the COPY SendCommand.
| PARAMETER | DESCRIPTION |
|---|---|
handles
|
List of entity handle strings to copy.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the copy command was issued successfully, False otherwise. |
paste_entities
¶
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:
|
base_point_y
|
Y coordinate of the paste base point (drawing units).
TYPE:
|
| 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 the color of the specified entities via COM.
| PARAMETER | DESCRIPTION |
|---|---|
handles
|
List of entity handle strings to recolor.
TYPE:
|
color
|
New color as a name (e.g.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if at least one entity's color was changed, False otherwise. |
change_entity_layer
¶
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:
|
layer_name
|
Name of the destination layer.
TYPE:
|
| 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:
|
rows
|
Number of rows in the grid.
TYPE:
|
columns
|
Number of columns in the grid.
TYPE:
|
row_spacing
|
Distance between rows (drawing units, Y direction).
TYPE:
|
column_spacing
|
Distance between columns (drawing units, X direction).
TYPE:
|
| 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:
|
center_x
|
X coordinate of the array centre (drawing units).
TYPE:
|
center_y
|
Y coordinate of the array centre (drawing units).
TYPE:
|
count
|
Total number of items in the array (including the original).
TYPE:
|
angle_to_fill
|
Total arc angle to distribute copies over (default: 360.0°).
TYPE:
|
rotate_items
|
When True, each copy is also rotated to face outward.
TYPE:
|
| 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:
|
path_points
|
Ordered list of 2-D or 3-D points defining the path.
TYPE:
|
count
|
Total number of items in the array (including the original).
TYPE:
|
align_items
|
When True, each copy is rotated to align with the local path direction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
List of handle strings for the newly created copy entities. |