Skip to content

Selection Mixin

Entity selection by color, layer, or type; selection info and clipboard state.

adapters.mixins.selection_mixin.SelectionMixin

Mixin for selection operations.

select_by_color

select_by_color(color: str | int) -> List[str]

Select all entities matching the given color and return their handles.

PARAMETER DESCRIPTION
color

Color name (e.g. "red") or ACI index (1–255).

TYPE: str | int

RETURNS DESCRIPTION
List[str]

List of entity handle strings for matching entities.

select_by_layer

select_by_layer(layer_name: str) -> List[str]

Select all entities residing on the specified layer and return their handles.

PARAMETER DESCRIPTION
layer_name

Exact layer name (case-insensitive comparison is used).

TYPE: str

RETURNS DESCRIPTION
List[str]

List of entity handle strings for entities on the given layer.

select_by_type

select_by_type(entity_type: str) -> List[str]

Select all entities of a given type and return their handles.

Accepts user-friendly names ("line", "circle", "arc", "polyline", "text", "point") or raw AutoCAD ObjectName strings.

PARAMETER DESCRIPTION
entity_type

Entity type name (user-friendly or AutoCAD ObjectName).

TYPE: str

RETURNS DESCRIPTION
List[str]

List of entity handle strings for matching entities.

get_selected_entities

get_selected_entities() -> List[str]

Return handles of all currently selected entities via a temporary SelectionSet.

RETURNS DESCRIPTION
List[str]

List of entity handle strings. Empty list if nothing is selected or on error.

clear_selection

clear_selection() -> bool

Deselect all currently selected entities in the active document.

RETURNS DESCRIPTION
bool

True if cleared successfully, False otherwise.

has_selection

has_selection() -> bool

Check if any entities are currently selected.

RETURNS DESCRIPTION
bool

True if at least one entity is selected, False otherwise

get_selected_entity_handles

get_selected_entity_handles() -> list[str]

Get list of currently selected entity handles.

RETURNS DESCRIPTION
list[str]

List of entity handles (strings). Empty list if no selection.

get_selection_info

get_selection_info() -> dict[str, Any]

Get comprehensive information about current selection.

RETURNS DESCRIPTION
dict[str, Any]

Dictionary with:

dict[str, Any]
  • count: Number of selected entities
dict[str, Any]
  • handles: List of entity handles
dict[str, Any]
  • types: List of entity ObjectNames
dict[str, Any]
  • layers: Set of layers containing selected entities