View Operations
About 1 min
View Operations
Operations related to view zooming, panning, redraw, and coordinate-system conversion.
Online Examples
| Example | Description | Link |
|---|---|---|
| Zoom Extents | Usage of zoomExtents | Online Demo{target="_blank"} |
| Zoom to Entities | Usage of zoomToEntities | Online Demo{target="_blank"} |
| Refresh Display | Usage of render, redraw, and regen | Online Demo{target="_blank"} |
| Preview Drawing | Usage of drawPreviewEntity | Online Demo{target="_blank"} |
| Set View Center | Usage of setCenter | Online Demo{target="_blank"} |
| Background Color | Usage of setBgc | Online Demo{target="_blank"} |
| Screen Bounds | Usage of getScreenBoundsWcs and getScreenEntities | Online Demo{target="_blank"} |
| Coordinate Conversion | Usage of canvasToWcs, wcsToUcs, and wcsToDcs | Online Demo{target="_blank"} |
| Zoom Factor | Usage of ZOOMFACTOR and currentSpace.zoom | Online Demo{target="_blank"} |
| UCS | User coordinate system setup example | Online Demo{target="_blank"} |
| Plan View | Rotate drawing by 60 degrees using UCS and then switch to plan view | Online Demo{target="_blank"} |
Core API
Zoom Operations
// Zoom to full extents
Engine.zoomExtents();
// Zoom to specific entities
Engine.zoomToEntities([entity1, entity2]);
// Zoom to specific bounds
Engine.zoomToBounds(new BoundingBox(0, 0, 1000, 1000));
// Set zoom factor
Engine.setZoom(2.0); // Zoom in 2xView Center
// Set view center
Engine.setCenter(new Point2D(500, 500));
// Get current view center
const center = Engine.getCenter();Redraw Operations
// Lightweight refresh
Engine.render();
// Standard refresh
Engine.redraw();
// Full regeneration
Engine.regen();Coordinate Conversion
// Canvas coordinates -> WCS
const wcsPoint = Engine.canvasToWcs(canvasX, canvasY);
// WCS -> UCS
const ucsPoint = Engine.wcsToUcs(wcsPoint);
// WCS -> DCS
const dcsPoint = Engine.wcsToDcs(wcsPoint);Screen Bounds
// Get visible WCS bounds of current screen
const bounds = Engine.getScreenBoundsWcs();
// Get entities currently visible on screen
const visibleEntities = Engine.getScreenEntities();Background Color
// Set background color
Engine.setBgc('#1a1a2e'); // Dark background
Engine.setBgc('#ffffff'); // White background