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:
|
end
|
End coordinate as (x, y) or (x, y, z).
TYPE:
|
layer
|
Layer name for the entity (default:
TYPE:
|
color
|
Color name or ACI index (default:
TYPE:
|
lineweight
|
Line weight in hundredths of mm; 0 uses default.
TYPE:
|
_skip_refresh
|
Internal flag to skip view refresh (used for batch operations).
TYPE:
|
| 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:
|
radius
|
Circle radius in drawing units. Must be positive.
TYPE:
|
layer
|
Layer name for the entity (default:
TYPE:
|
color
|
Color name or ACI index (default:
TYPE:
|
lineweight
|
Line weight in hundredths of mm; 0 uses default.
TYPE:
|
_skip_refresh
|
Internal flag to skip view refresh (used for batch operations).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Handle string of the created circle entity. |
| RAISES | DESCRIPTION |
|---|---|
InvalidParameterError
|
If |
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:
|
radius
|
Arc radius in drawing units.
TYPE:
|
start_angle
|
Start angle in degrees (0 = East, counter-clockwise).
TYPE:
|
end_angle
|
End angle in degrees.
TYPE:
|
layer
|
Layer name for the entity (default:
TYPE:
|
color
|
Color name or ACI index (default:
TYPE:
|
lineweight
|
Line weight in hundredths of mm; 0 uses default.
TYPE:
|
_skip_refresh
|
Internal flag to skip view refresh (used for batch operations).
TYPE:
|
| 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:
|
corner2
|
Opposite corner coordinate as (x, y) or (x, y, z).
TYPE:
|
layer
|
Layer name for the entity (default:
TYPE:
|
color
|
Color name or ACI index (default:
TYPE:
|
lineweight
|
Line weight in hundredths of mm; 0 uses default.
TYPE:
|
_skip_refresh
|
Internal flag to skip view refresh (used for batch operations).
TYPE:
|
| 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:
|
closed
|
When True, close the polyline back to the first point.
TYPE:
|
layer
|
Layer name for the entity (default:
TYPE:
|
color
|
Color name or ACI index (default:
TYPE:
|
lineweight
|
Line weight in hundredths of mm; 0 uses default.
TYPE:
|
_skip_refresh
|
Internal flag to skip view refresh (used for batch operations).
TYPE:
|
| 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:
|
major_axis_end
|
End point of the major axis, relative to the centre.
TYPE:
|
minor_axis_ratio
|
Ratio of the minor axis to the major axis (0 < ratio <= 1).
TYPE:
|
layer
|
Layer name for the entity (default:
TYPE:
|
color
|
Color name or ACI index (default:
TYPE:
|
lineweight
|
Line weight in hundredths of mm; 0 uses default.
TYPE:
|
_skip_refresh
|
Internal flag to skip view refresh (used for batch operations).
TYPE:
|
| 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:
|
text
|
Text string to display.
TYPE:
|
height
|
Text height in drawing units (default: 2.5).
TYPE:
|
rotation
|
Rotation angle in degrees, measured counter-clockwise (default: 0.0).
TYPE:
|
layer
|
Layer name for the entity (default:
TYPE:
|
color
|
Color name or ACI index (default:
TYPE:
|
_skip_refresh
|
Internal flag to skip view refresh (used for batch operations).
TYPE:
|
| 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:
|
pattern
|
Hatch pattern name (e.g.
TYPE:
|
scale
|
Hatch pattern scale factor (default: 1.0).
TYPE:
|
angle
|
Hatch pattern angle in degrees (default: 0.0).
TYPE:
|
color
|
Color name or ACI index (default:
TYPE:
|
layer
|
Layer name for the entity (default:
TYPE:
|
| 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:
|
end
|
End point of the dimension
TYPE:
|
text
|
Custom dimension text (optional)
TYPE:
|
layer
|
Layer name
TYPE:
|
color
|
Color name or index
TYPE:
|
offset
|
Distance to offset the dimension line from the edge (default: 10.0)
TYPE:
|
_skip_refresh
|
Internal flag to skip view refresh (used for batch operations)
TYPE:
|
| 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:
|
closed
|
When True, close the spline back to the first point.
TYPE:
|
degree
|
Polynomial degree of the spline (1, 2, or 3). Default: 3.
TYPE:
|
layer
|
Layer name for the entity (default:
TYPE:
|
color
|
Color name or ACI index (default:
TYPE:
|
lineweight
|
Line weight in hundredths of mm; 0 uses default.
TYPE:
|
_skip_refresh
|
Internal flag to skip view refresh (used for batch operations).
TYPE:
|
| 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:
|
text
|
Optional annotation text to attach at the base point.
TYPE:
|
text_height
|
Text height in drawing units (default: 2.5).
TYPE:
|
layer
|
Layer name for the entity (default:
TYPE:
|
color
|
Color name or ACI index (default:
TYPE:
|
leader_type
|
Arrow style — one of
TYPE:
|
_skip_refresh
|
Internal flag to skip view refresh (used for batch operations).
TYPE:
|
| 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:
|
leader_groups
|
List of point lists, each defining one leader line. Order: [ArrowHead, ..., TextPosition]
TYPE:
|
_skip_refresh
|
Internal flag to skip view refresh (used for batch operations)
TYPE:
|