Built-in Plugins
MLightCAD ships a set of first-party plugins. Each plugin focuses on one concern — UI chrome, an AI assistant, export/import pipelines, or cloud data sources — and can be combined as needed.
For the plugin mechanism itself (AcApPlugin, the plugin manager, lazy loading, and how to write your own plugin), see Plugin System. Installation, registration, and full API details live in each package's README — see the links below.
Plugin overview
| Package | Role | Commands / capabilities |
|---|---|---|
@mlightcad/cad-agent-plugin | Natural-language CAD agent (AI chat panel + drawing tool calls) | agent |
@mlightcad/cad-script-plugin | Manual CAD script console (runs checked scripts against the drawing, no LLM / API key needed) | cadscript |
@mlightcad/cad-html-plugin | Export drawings to self-contained offline HTML | chtml (dialog in cad-editor), -chtml (command-line) |
@mlightcad/cad-pdf-plugin | PDF export and import (vector pipeline) | cpdf, pdfimport, -pdfimport |
@mlightcad/cad-svg-plugin | SVG export and shared vector renderer (also used by PDF export) | csvg |
@mlightcad/cad-svg-converter | SVG File → Open (basic vector subset → AcDb entities) | Host calls registerSvgConverter() (cad-editor does this in initializeCadViewer) |
@mlightcad/cad-onedrive-plugin | OneDrive data source — open DWG/DXF from OneDrive / SharePoint | Registers AcApDataSource (onedrive); two-step Sign in → Open (popup-safe) |
@mlightcad/cad-google-drive-plugin | Google Drive data source — open DWG/DXF from Google Drive | Registers AcApDataSource (googledrive); two-step Sign in → Open (popup-safe) |
All command-triggered plugins are lazy-loaded: a small registration stub is registered up front and the heavy bundle downloads only when the user runs the trigger command. See Plugin System — Registering plugins for the registration API.
UI plugins
@mlightcad/cad-simple-ui-plugin — UI chrome for the simple viewer
cad-simple-viewer ships the canvas, CAD core, and shared plain-DOM chrome such as AcUiDockPanel (also the default host for AcApPaletteService when no app UI is registered). If you embed the simple viewer and want ready-made toolbar and palette tabs without adopting the full Vue-based cad-editor shell, cad-simple-ui-plugin was the intended UI layer.
It provides:
- A configurable toolbar (placement on any edge, default CAD commands, nested menus, custom items)
- Dock tab content for layers, find, review, and measurements, mounted in the shared
AcUiDockPanelchrome (layer on/off, ACI color picker, zoom-to-layer on double-click; markup list; find; measurements) - An
AcApPaletteHostso command panels (andAcApPaletteService.openNamedTab) use the dock;cad-editorregisters a Vue tool-palette host instead and switches automatically - Theme sync with the
COLORTHEMEsysvar and--ml-ui-*CSS tokens on your host element - Locale sync with
AcApI18n(English / Chinese / Czech / Turkish / Japanese / Korean / Arabic)
All widgets are framework-agnostic (plain DOM). The full Vue cad-editor app has its own Element Plus UI and does not require this chrome; use it when you build on cad-simple-viewer directly.
Since 1.8.0 — merged into cad-simple-viewer
Starting with 1.8.0, the separate npm package @mlightcad/cad-simple-ui-plugin is removed. The same toolbar / dock tabs / palette host live inside @mlightcad/cad-simple-viewer (no /simple-ui subpath).
- Default on: pass options through
AcApDocManager.createInstance({ simpleUi: { … } })(or omitsimpleUito enable defaults). Chrome loads via a dynamic import so hosts that setsimpleUi: false(cad-editor, CLI, MCP, …) do not download that chunk. - Types / helpers: import from
@mlightcad/cad-simple-viewer. - Await ready: use
simpleUiReady/simpleUiinstead ofpluginManager.getPlugin('SimpleUiPlugin').
AcApDocManager.createInstance({
container,
simpleUi: {
toolbar: { placement: 'right', items: 'default' }
}
})
// Opt out: simpleUi: falseSee the upgrade guide for the full migration from @mlightcad/cad-simple-ui-plugin.
@mlightcad/cad-agent-plugin — AI drawing assistant
cad-agent-plugin adds a natural-language CAD agent to cad-simple-viewer-based apps. Users describe what they want in plain language; the agent calls CAD tools to inspect the drawing and create or modify geometry.
It provides:
- A lazy-loaded
AcApPlugin(trigger command:agent) so the AI bundle is not on the critical path - A Vue chat panel (
AgentChatPanel) built on the Vercel AI SDK (Experimental_Agent+@ai-sdk/vue) - Browser-side LLM configuration — API keys for OpenAI, Anthropic, or OpenAI-compatible endpoints stay in the client (encrypted in
localStorage) - Phase 1 CAD tools —
get_drawing_context;draw_line,draw_circle,draw_arc,draw_rectangle,draw_polyline,draw_text;set_current_layer,create_layer,zoom_extents - English / Chinese / Turkish / Czech UI strings via the plugin i18n layer
The full Vue cad-editor app registers the agent automatically when the package is installed (palette tab). cad-simple-viewer-demo wires it into a dock tab via built-in simple UI chrome (simpleUi). Host apps call registerLazyAgentPlugin and setAgentPaletteOpener to mount the panel where they want.
→ Installation, registration, and tool list: packages/cad-agent-plugin/README.md
@mlightcad/cad-script-plugin — CAD script console
cad-script-plugin adds a manual CAD script console for cad-simple-viewer-based apps. Unlike the agent plugin, it does not talk to a model and needs no API key: the console runs the checked script host from @mlightcad/cad-agent-core, and each script is a function body with one argument, cad, giving programmatic access to the same drawing tools the agent uses.
- Lazy-loaded
AcApPlugin(trigger command:cadscript) - Reuses the CAD tools from
@mlightcad/cad-agent-core; this package only adds the panel and the command - Host apps call
registerLazyCadScriptPluginand mountnew CadScriptPanel().element(dock tab incad-simple-viewer-demo, tool-palette tab incad-editor); calldestroy()when the tab is removed
→ Usage: packages/cad-script-plugin/README.md
Export / import plugins (HTML / PDF / SVG)
These plugins add export (and PDF import) commands to the same plugin manager. They are lazy-loaded so initial page weight stays small. The cad-simple-viewer-demo demo registers all three export plugins plus the UI/agent/script plugins; the full cad-editor app registers the export plugins and the agent/script plugins (when installed) in its bootstrap.
HTML (@mlightcad/cad-html-plugin)
One-file offline viewer for sharing and archiving — the exported HTML embeds the drawing data and a runtime viewer, no server required.
| Item | Value |
|---|---|
| Command | chtml (dialog in cad-editor), -chtml (command-line via cad-simple-viewer-cli) |
| Extra config | htmlViewerRuntimeUrl on AcApDocManager.createInstance() — URL to viewer-runtime.iife.js (copy from package dist/) |
| Public API | registerLazyHtmlPlugin, createHtmlPlugin, AcApHtmlConvertor, acexHtmlPackHtml, snapshot types (acexHtml* / AcExHtml* from 1.8.0; see upgrade guide) |
→ Build output and integration: packages/cad-html-plugin/README.md → Headless CLI using the same pipeline: packages/cad-simple-viewer-cli/README.md
PDF (@mlightcad/cad-pdf-plugin)
Vector PDF export and PDF-to-CAD import. From 1.8.0, export logic lives in shared @mlightcad/cad-pdf-core (no viewer / DOM). The browser plugin and the headless @mlightcad/cad-pdf-exporter (exportFileToPdf, convertDatabaseToPdf) both use that core — Node can export PDF without a browser. Browser commands and convertors keep their names; export options gain colorMode: 'color' | 'monochrome'.
| Item | Value |
|---|---|
| Commands | cpdf (export), pdfimport (import) |
| Public API | registerLazyPdfPlugin, createPdfPlugin, AcApPdfConvertor, resolveAcApPdfExportOptions |
→ Build output and integration: packages/cad-pdf-plugin/README.md → Headless Node exporter (same core): packages/cad-pdf-exporter/README.md → 1.8.0 upgrade notes: upgrade guide
SVG (@mlightcad/cad-svg-plugin)
Vector SVG export and the shared vector renderer used by PDF export.
| Item | Value |
|---|---|
| Command | csvg |
| Public API | registerLazySvgPlugin, createSvgPlugin, AcApSvgConvertor, SVG renderer utilities |
→ Build output and integration: packages/cad-svg-plugin/README.md
SVG open (@mlightcad/cad-svg-converter)
SVG → AcDbDatabase converter for File → Open. Not a command plugin — hosts register it once with registerSvgConverter() (same pattern as LibreDWG). cad-editor registers it inside initializeCadViewer. Local open UI accepts .svg alongside .dwg / .dxf.
| Item | Value |
|---|---|
| Converter key | 'svg' (ACDB_SVG_FILE_TYPE) |
| Public API | registerSvgConverter, AcDbSvgConverter, acdbSvgParseDocument |
| Supported subset | line, polyline/polygon/rect, circle, ellipse (approx), path, text, g + transforms |
→ Build output and integration: packages/cad-svg-converter/README.md → 1.8.0 upgrade notes: upgrade guide
Data source plugins (OneDrive / Google Drive)
These plugins do not register commands — they register an AcApDataSource so users can open DWG/DXF drawings directly from cloud storage. Both use a two-step Sign in → Open flow designed to stay popup-blocker-safe.
@mlightcad/cad-onedrive-plugin
OneDrive / SharePoint data source built on Microsoft File Picker v8 + MSAL. Requires an Azure app registration (SPA, delegated User.Read + Files.Read.All permissions).
import { registerOneDrivePlugin } from '@mlightcad/cad-onedrive-plugin/register'
await registerOneDrivePlugin(AcApDocManager.instance.pluginManager, {
clientId: 'your-azure-app-client-id'
})→ Azure app setup and full integration: packages/cad-onedrive-plugin/README.md and Data Source Plugin
@mlightcad/cad-google-drive-plugin
Google Drive data source with the same AcApDataSource contract.
import { registerGoogleDrivePlugin } from '@mlightcad/cad-google-drive-plugin/register'
await registerGoogleDrivePlugin(AcApDocManager.instance.pluginManager, {
clientId: 'your-google-oauth-client-id'
})→ Google Cloud setup and full integration: packages/cad-google-drive-plugin/README.md
Which plugins does each app register?
| App | Registered plugins |
|---|---|
cad-simple-viewer | None — core only, plugins are optional |
cad-simple-viewer-demo | Export plugins (HTML/PDF/SVG), built-in simple UI chrome (simpleUi, formerly cad-simple-ui-plugin), cad-agent-plugin, cad-script-plugin |
cad-editor (Vue) | Export plugins (HTML/PDF/SVG); agent and script plugins are registered automatically when installed (optional peers) |
Related documentation
- Plugin System —
AcApPlugininterface, plugin manager, lazy loading, and writing your own plugin - Data Source Plugin — the
AcApDataSourcemechanism used by the OneDrive / Google Drive plugins - Command — command lifecycle and
AcEdCommand