Skip to content

View Mixin

Viewport operations (zoom), undo/redo history, screenshot capture, and view export.

adapters.mixins.view_mixin.ViewMixin

Mixin for view operations.

get_screenshot

get_screenshot() -> Dict[str, str]

Capture a screenshot of the CAD application window.

RETURNS DESCRIPTION
dict

Dictionary with 'path' and 'data' (base64)

TYPE: Dict[str, str]

RAISES DESCRIPTION
Exception

If screenshot fails

export_view

export_view() -> Dict[str, str]

Export current view using internal PNGOUT command.

This method uses ZWCAD's built-in PNGOUT command to export the drawing view to a PNG file. Unlike get_screenshot(), this method: - Works even if the window is minimized or obscured - Captures only the drawing content (no UI chrome) - Uses the CAD application's internal rendering

RETURNS DESCRIPTION
Dict[str, str]

Dictionary with 'path' and 'data' (base64 encoded image)

RAISES DESCRIPTION
Exception

If export fails

zoom_extents

zoom_extents() -> bool

Zoom the active viewport to fit all drawing entities via COM.

RETURNS DESCRIPTION
bool

True if successful, False otherwise.

refresh_view

refresh_view() -> bool

Refresh the view using multiple techniques for maximum compatibility.

Uses a combination of techniques in fallback order: 1. Application.Refresh() (COM API - no undo/redo impact) 2. SendCommand with REDRAW (most reliable visual update) 3. Window click simulation (forces UI update)

Note: REDRAW command is not wrapped in UNDO to avoid complicating the undo/redo stack. If refresh_view is called during user operations, the REDRAW will be undone by the user's undo command anyway.

RETURNS DESCRIPTION
bool

True if refresh was attempted (best effort approach)

undo

undo(count: int = 1) -> bool

Undo last action(s).

PARAMETER DESCRIPTION
count

Number of operations to undo (default: 1)

TYPE: int DEFAULT: 1

RETURNS DESCRIPTION
bool

True if successful, False otherwise

redo

redo(count: int = 1) -> bool

Redo last undone action(s).

PARAMETER DESCRIPTION
count

Number of operations to redo (default: 1)

TYPE: int DEFAULT: 1

RETURNS DESCRIPTION
bool

True if successful, False otherwise