View Mixin¶
Viewport operations (zoom), undo/redo history, screenshot capture, and view export.
adapters.mixins.view_mixin.ViewMixin
¶
Mixin for view operations.
get_screenshot
¶
Capture a screenshot of the CAD application window.
| RETURNS | DESCRIPTION |
|---|---|
dict
|
Dictionary with 'path' and 'data' (base64)
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If screenshot fails |
export_view
¶
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 the active viewport to fit all drawing entities via COM.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if successful, False otherwise. |
refresh_view
¶
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 last action(s).
| PARAMETER | DESCRIPTION |
|---|---|
count
|
Number of operations to undo (default: 1)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if successful, False otherwise |
redo
¶
Redo last undone action(s).
| PARAMETER | DESCRIPTION |
|---|---|
count
|
Number of operations to redo (default: 1)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if successful, False otherwise |