CAD Viewer is a high-performance Vue 3 component for viewing and editing CAD files (DXF, DWG) entirely in the browser without requiring any backend server. It provides a modern user interface, state management, and seamless integration with optimized rendering engines for smooth browser-based CAD workflows with exceptional performance.
Use cad-viewer
if you want a ready-to-use Vue 3 component for viewing and editing CAD files with a modern UI, dialogs, toolbars, and state management. This package is ideal if:
Recommended for: Most web applications, dashboards, or platforms that need to display CAD files with a polished user interface.
This Vue 3 component operates entirely in the browser with no backend dependencies. DWG/DXF files are parsed and processed locally using WebAssembly and JavaScript, providing:
src/app/
– Application entry, store, and main logicsrc/component/
– UI components (dialogs, toolbars, status bar, etc.)src/composable/
– Vue composables for state and logicsrc/locale/
– Internationalization filessrc/style/
– Stylesheetssrc/svg/
– SVG assetsnpm install @mlightcad/cad-viewer
Please refer to sub-package cad-viewer-example
as one example.
Firstly, add the following dependencies into your package.json.
Then create one vue component as follows.
The MlCadViewer
is the main Vue 3 component that provides a complete CAD viewing and editing interface. It includes toolbars, layer management, command line, status bar, and various dialogs for a full-featured CAD experience.
The MlCadViewer
component accepts the following props:
Property | Type | Default | Description |
---|---|---|---|
locale |
'en' | 'zh' | 'default' |
'default' |
Sets the language for the component interface. Use 'en' for English, 'zh' for Chinese, or 'default' to use the browser's default language. |
url |
string |
undefined |
Optional URL to automatically load a CAD file when the component mounts. The file will be fetched and opened automatically. |
wait |
number |
10 |
When set to a positive number, the component will wait for DWG converter ready for use for the specified number of seconds before initializing. This is useful when you need to ensure DWG file support is available before the component becomes interactive. Set to 0 or negative value to disable waiting. |
The MlCadViewer
component includes:
The component automatically handles various events:
Please refer to readme of cad-simple-viewer to learn the following advanced usage.
MlCADViewer
- The main CAD viewer componentAcApLayerStateCmd
- Layer state commandAcApLogCmd
- Log commandAcApMissedDataCmd
- Missed data commandAcApPointStyleCmd
- Point style commandMlPointStyleDlg
- Point style dialogMlReplacementDlg
- Replacement dialoguseCommands
- Command managementuseCurrentPos
- Current position trackinguseDark
- Dark mode supportuseDialogManager
- Dialog managementuseFileTypes
- File type utilitiesuseLayers
- Layer managementuseLayouts
- Layout managementuseMissedData
- Missed data handlinguseSettings
- Settings managementuseSystemVars
- System variablesi18n
- Internationalization instance# Install dependencies
pnpm install
# Start development server
pnpm dev
# Build the library
pnpm build
# Preview the build
pnpm preview
MIT