This package provides the high-performance core components of a CAD viewer such as document management, command handling, and collaboration between the UI and rendering engines. It's designed for optimal performance when handling large CAD files.
This module doesn't depend on any UI framework and doesn't provide any UI except canvas. If you want to integrate a high-performance CAD viewer into a web application with your own UI, this module is the correct choice.
Use cad-simple-viewer
if you need core CAD logic only (document management, command stack, rendering engine integration) without any UI framework dependencies. This package is ideal if:
Recommended for: Custom integrations, headless CAD processing, or advanced users building highly tailored CAD solutions.
src/app/
– Document/context management, settingssrc/command/
– Command implementations (open, zoom, select, etc.)src/editor/
– Command stack, input handling, global functionssrc/view/
– Layout and scene managementsrc/util/
– Utilitiesnpm install @mlightcad/cad-simple-viewer
Please refer to cad-simple-viewer-example on basic usage and advanced usage.
While cad-simple-viewer
doesn't support saving drawings to DWG/DXF files, it provides comprehensive support for modifying drawings in real-time. You can add, edit, and delete entities within the drawing, and the viewer will automatically update to reflect these changes.
When you modify entities, you're working directly with the underlying drawing database. The viewer automatically detects these changes and updates the display accordingly. This real-time synchronization ensures that:
This capability makes cad-simple-viewer
suitable for applications that need to not only display CAD files but also allow users to interact with and modify the drawing content.
Important Note: The usage patterns in cad-simple-viewer
are very similar to AutoCAD RealDWG. If you're familiar with AutoCAD RealDWG development, you'll find the API structure and workflow nearly identical. The main difference is that we use the realdwg-web API instead of the native RealDWG libraries.
In cad-simple-viewer-example it demonstrates how to create one drawing with realdwg-web API.
AcApContext
- Main application contextAcApDocManager
- Document managementAcApDocument
- Individual document handlingAcApSettingManager
- Settings managementAcApOpenCmd
- Open file commandAcApZoomCmd
- Zoom commandAcApPanCmd
- Pan commandAcApSelectCmd
- Selection commandAcApConvertToSvgCmd
- SVG conversion commandAcEditor
- Main editor classAcEdCommandStack
- Command stack managementAcEdSelectionSet
- Selection handlingAcEdInputPoint
- Input point managementAcTrScene
- Scene managementAcTrLayoutView
- Layout view handlingAcTrView2d
- 2D view managementThis package acts as the core logic layer, connecting the frontend UI with the rendering engines and managing all document-related operations.
MIT