Skip to content

File Mixin

Drawing file operations: open, save, close, new, and multi-drawing management.

adapters.mixins.file_mixin.FileMixin

Mixin for file operations.

save_drawing

save_drawing(
    filepath: str = "",
    filename: str = "",
    format: str = "dwg",
) -> bool

Save drawing to file.

PARAMETER DESCRIPTION
filepath

Full path to save file (e.g., 'C:/drawings/myfile.dwg')

TYPE: str DEFAULT: ''

filename

Just the filename (e.g., 'myfile.dwg'). If provided without filepath, uses configured output directory

TYPE: str DEFAULT: ''

format

File format (dwg, dxf, etc.). Default: dwg

TYPE: str DEFAULT: 'dwg'

RETURNS DESCRIPTION
bool

True if successful, False otherwise

TYPE: bool

Note
  • If both filepath and filename provided, filepath takes precedence
  • If only filename provided, saved to config output directory
  • If neither provided, uses current document name

open_drawing

open_drawing(filepath: str) -> bool

Open a drawing file in the CAD application via COM.

PARAMETER DESCRIPTION
filepath

Absolute path to the drawing file to open (e.g. C:/drawings/plan.dwg).

TYPE: str

RETURNS DESCRIPTION
bool

True if the file was opened successfully, False otherwise.

new_drawing

new_drawing() -> bool

Create a new blank drawing document in the CAD application via COM.

RETURNS DESCRIPTION
bool

True if the document was created successfully, False otherwise.

get_open_drawings

get_open_drawings() -> list

Get list of all open drawing filenames.

RETURNS DESCRIPTION
list

List of drawing names (e.g., ["drawing1.dwg", "drawing2.dwg"])

switch_drawing

switch_drawing(drawing_name: str) -> bool

Switch to a different open drawing.

PARAMETER DESCRIPTION
drawing_name

Name of the drawing to switch to (e.g., "drawing1.dwg")

TYPE: str

RETURNS DESCRIPTION
bool

True if successful, False otherwise

close_drawing

close_drawing(save_changes: bool = False) -> bool

Close the current drawing.

PARAMETER DESCRIPTION
save_changes

Whether to save changes before closing (default: False) True = save changes False = discard changes without prompting

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
bool

True if successful, False otherwise