Skip to content

Drawing Mixin

Creates geometric entities in the active CAD drawing via COM.

Supported entity types: line, circle, arc, rectangle, polyline, text, spline, hatch, ellipse, dimension, leader/mleader.

adapters.mixins.drawing_mixin.DrawingMixin

Mixin for drawing operations.

draw_line

draw_line(
    start: Coordinate,
    end: Coordinate,
    layer: str = "0",
    color: str | int = "white",
    lineweight: int = 0,
    _skip_refresh: bool = False,
) -> str

Draw a line between two points via COM AddLine().

PARAMETER DESCRIPTION
start

Start coordinate as (x, y) or (x, y, z).

TYPE: Coordinate

end

End coordinate as (x, y) or (x, y, z).

TYPE: Coordinate

layer

Layer name for the entity (default: "0").

TYPE: str DEFAULT: '0'

color

Color name or ACI index (default: "white").

TYPE: str | int DEFAULT: 'white'

lineweight

Line weight in hundredths of mm; 0 uses default.

TYPE: int DEFAULT: 0

_skip_refresh

Internal flag to skip view refresh (used for batch operations).

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

Handle string of the created line entity.

draw_circle

draw_circle(
    center: Coordinate,
    radius: float,
    layer: str = "0",
    color: str | int = "white",
    lineweight: int = 0,
    _skip_refresh: bool = False,
) -> str

Draw a circle via COM AddCircle().

PARAMETER DESCRIPTION
center

Centre coordinate as (x, y) or (x, y, z).

TYPE: Coordinate

radius

Circle radius in drawing units. Must be positive.

TYPE: float

layer

Layer name for the entity (default: "0").

TYPE: str DEFAULT: '0'

color

Color name or ACI index (default: "white").

TYPE: str | int DEFAULT: 'white'

lineweight

Line weight in hundredths of mm; 0 uses default.

TYPE: int DEFAULT: 0

_skip_refresh

Internal flag to skip view refresh (used for batch operations).

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

Handle string of the created circle entity.

RAISES DESCRIPTION
InvalidParameterError

If radius is not positive.

draw_arc

draw_arc(
    center: Coordinate,
    radius: float,
    start_angle: float,
    end_angle: float,
    layer: str = "0",
    color: str | int = "white",
    lineweight: int = 0,
    _skip_refresh: bool = False,
) -> str

Draw an arc via COM AddArc().

PARAMETER DESCRIPTION
center

Centre coordinate as (x, y) or (x, y, z).

TYPE: Coordinate

radius

Arc radius in drawing units.

TYPE: float

start_angle

Start angle in degrees (0 = East, counter-clockwise).

TYPE: float

end_angle

End angle in degrees.

TYPE: float

layer

Layer name for the entity (default: "0").

TYPE: str DEFAULT: '0'

color

Color name or ACI index (default: "white").

TYPE: str | int DEFAULT: 'white'

lineweight

Line weight in hundredths of mm; 0 uses default.

TYPE: int DEFAULT: 0

_skip_refresh

Internal flag to skip view refresh (used for batch operations).

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

Handle string of the created arc entity.

draw_rectangle

draw_rectangle(
    corner1: Coordinate,
    corner2: Coordinate,
    layer: str = "0",
    color: str | int = "white",
    lineweight: int = 0,
    _skip_refresh: bool = False,
) -> str

Draw a rectangle from two opposite corner coordinates via a closed polyline.

PARAMETER DESCRIPTION
corner1

First corner coordinate as (x, y) or (x, y, z).

TYPE: Coordinate

corner2

Opposite corner coordinate as (x, y) or (x, y, z).

TYPE: Coordinate

layer

Layer name for the entity (default: "0").

TYPE: str DEFAULT: '0'

color

Color name or ACI index (default: "white").

TYPE: str | int DEFAULT: 'white'

lineweight

Line weight in hundredths of mm; 0 uses default.

TYPE: int DEFAULT: 0

_skip_refresh

Internal flag to skip view refresh (used for batch operations).

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

Handle string of the created polyline entity.

draw_polyline

draw_polyline(
    points: List[Coordinate],
    closed: bool = False,
    layer: str = "0",
    color: str | int = "white",
    lineweight: int = 0,
    _skip_refresh: bool = False,
) -> str

Draw a polyline through a sequence of points via COM AddPolyline().

PARAMETER DESCRIPTION
points

Ordered list of at least 2 coordinates, each as (x, y) or (x, y, z).

TYPE: List[Coordinate]

closed

When True, close the polyline back to the first point.

TYPE: bool DEFAULT: False

layer

Layer name for the entity (default: "0").

TYPE: str DEFAULT: '0'

color

Color name or ACI index (default: "white").

TYPE: str | int DEFAULT: 'white'

lineweight

Line weight in hundredths of mm; 0 uses default.

TYPE: int DEFAULT: 0

_skip_refresh

Internal flag to skip view refresh (used for batch operations).

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

Handle string of the created polyline entity.

RAISES DESCRIPTION
InvalidParameterError

If fewer than 2 points are provided.

draw_ellipse

draw_ellipse(
    center: Coordinate,
    major_axis_end: Coordinate,
    minor_axis_ratio: float,
    layer: str = "0",
    color: str | int = "white",
    lineweight: int = 0,
    _skip_refresh: bool = False,
) -> str

Draw an ellipse via COM AddEllipse().

PARAMETER DESCRIPTION
center

Centre coordinate as (x, y) or (x, y, z).

TYPE: Coordinate

major_axis_end

End point of the major axis, relative to the centre.

TYPE: Coordinate

minor_axis_ratio

Ratio of the minor axis to the major axis (0 < ratio <= 1).

TYPE: float

layer

Layer name for the entity (default: "0").

TYPE: str DEFAULT: '0'

color

Color name or ACI index (default: "white").

TYPE: str | int DEFAULT: 'white'

lineweight

Line weight in hundredths of mm; 0 uses default.

TYPE: int DEFAULT: 0

_skip_refresh

Internal flag to skip view refresh (used for batch operations).

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

Handle string of the created ellipse entity.

draw_text

draw_text(
    position: Coordinate,
    text: str,
    height: float = 2.5,
    rotation: float = 0.0,
    layer: str = "0",
    color: str | int = "white",
    _skip_refresh: bool = False,
) -> str

Add a single-line text entity to the drawing via COM AddText().

PARAMETER DESCRIPTION
position

Insertion point as (x, y) or (x, y, z).

TYPE: Coordinate

text

Text string to display.

TYPE: str

height

Text height in drawing units (default: 2.5).

TYPE: float DEFAULT: 2.5

rotation

Rotation angle in degrees, measured counter-clockwise (default: 0.0).

TYPE: float DEFAULT: 0.0

layer

Layer name for the entity (default: "0").

TYPE: str DEFAULT: '0'

color

Color name or ACI index (default: "white").

TYPE: str | int DEFAULT: 'white'

_skip_refresh

Internal flag to skip view refresh (used for batch operations).

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

Handle string of the created text entity.

draw_hatch

draw_hatch(
    boundary_points: List[Coordinate],
    pattern: str = "SOLID",
    scale: float = 1.0,
    angle: float = 0.0,
    color: str | int = "white",
    layer: str = "0",
) -> str

Create a hatch (filled area) bounded by a closed polyline via COM AddHatch().

PARAMETER DESCRIPTION
boundary_points

Ordered list of coordinates defining the boundary polygon.

TYPE: List[Coordinate]

pattern

Hatch pattern name (e.g. "SOLID", "ANSI31"). Default: "SOLID".

TYPE: str DEFAULT: 'SOLID'

scale

Hatch pattern scale factor (default: 1.0).

TYPE: float DEFAULT: 1.0

angle

Hatch pattern angle in degrees (default: 0.0).

TYPE: float DEFAULT: 0.0

color

Color name or ACI index (default: "white").

TYPE: str | int DEFAULT: 'white'

layer

Layer name for the entity (default: "0").

TYPE: str DEFAULT: '0'

RETURNS DESCRIPTION
str

Handle string of the created hatch entity.

add_dimension

add_dimension(
    start: Coordinate,
    end: Coordinate,
    text: Optional[str] = None,
    layer: str = "0",
    color: str | int = "white",
    offset: float = 10.0,
    _skip_refresh: bool = False,
) -> str

Add a dimension annotation with optional offset from the edge.

PARAMETER DESCRIPTION
start

Start point of the dimension

TYPE: Coordinate

end

End point of the dimension

TYPE: Coordinate

text

Custom dimension text (optional)

TYPE: Optional[str] DEFAULT: None

layer

Layer name

TYPE: str DEFAULT: '0'

color

Color name or index

TYPE: str | int DEFAULT: 'white'

offset

Distance to offset the dimension line from the edge (default: 10.0)

TYPE: float DEFAULT: 10.0

_skip_refresh

Internal flag to skip view refresh (used for batch operations)

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

Entity handle of the created dimension

draw_spline

draw_spline(
    points: List[Coordinate],
    closed: bool = False,
    degree: int = 3,
    layer: str = "0",
    color: str | int = "white",
    lineweight: int = 0,
    _skip_refresh: bool = False,
) -> str

Draw a NURBS spline curve through the given control points via COM AddSpline().

PARAMETER DESCRIPTION
points

Ordered list of at least 2 control-point coordinates.

TYPE: List[Coordinate]

closed

When True, close the spline back to the first point.

TYPE: bool DEFAULT: False

degree

Polynomial degree of the spline (1, 2, or 3). Default: 3.

TYPE: int DEFAULT: 3

layer

Layer name for the entity (default: "0").

TYPE: str DEFAULT: '0'

color

Color name or ACI index (default: "white").

TYPE: str | int DEFAULT: 'white'

lineweight

Line weight in hundredths of mm; 0 uses default.

TYPE: int DEFAULT: 0

_skip_refresh

Internal flag to skip view refresh (used for batch operations).

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

Handle string of the created spline entity.

RAISES DESCRIPTION
InvalidParameterError

If fewer than 2 points are provided or degree is outside 1–3.

draw_leader

draw_leader(
    points: List[Coordinate],
    text: Optional[str] = None,
    text_height: float = 2.5,
    layer: str = "0",
    color: str | int = "white",
    leader_type: str = "line_with_arrow",
    _skip_refresh: bool = False,
) -> str

Draw a leader line with an optional text annotation via draw_mleader().

Internally delegates to :meth:draw_mleader so that text is always rendered correctly. A single leader is created as a multi-leader with one arrow group.

PARAMETER DESCRIPTION
points

At least 2 coordinates defining the leader line (arrow to text).

TYPE: List[Coordinate]

text

Optional annotation text to attach at the base point.

TYPE: Optional[str] DEFAULT: None

text_height

Text height in drawing units (default: 2.5).

TYPE: float DEFAULT: 2.5

layer

Layer name for the entity (default: "0").

TYPE: str DEFAULT: '0'

color

Color name or ACI index (default: "white").

TYPE: str | int DEFAULT: 'white'

leader_type

Arrow style — one of "line_with_arrow", "line_no_arrow", "spline_with_arrow", "spline_no_arrow" (default: "line_with_arrow").

TYPE: str DEFAULT: 'line_with_arrow'

_skip_refresh

Internal flag to skip view refresh (used for batch operations).

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

Handle string of the created MLeader entity.

RAISES DESCRIPTION
InvalidParameterError

If fewer than 2 points are provided or leader_type is invalid.

draw_mleader

draw_mleader(
    base_point: Coordinate,
    leader_groups: List[List[Coordinate]],
    text: Optional[str] = None,
    text_height: float = 2.5,
    layer: str = "0",
    color: str | int = "white",
    arrow_style: str = "_ARROW",
    _skip_refresh: bool = False,
) -> str

Draw a multi-leader with multiple arrow lines.

PARAMETER DESCRIPTION
base_point

Base point for annotation (Text Position)

TYPE: Coordinate

leader_groups

List of point lists, each defining one leader line. Order: [ArrowHead, ..., TextPosition]

TYPE: List[List[Coordinate]]

_skip_refresh

Internal flag to skip view refresh (used for batch operations)

TYPE: bool DEFAULT: False