File Operations
About 1 min
File Operations
Operations for opening, saving, importing, and exporting files.
Online Examples
| Example | Description | Link |
|---|---|---|
| Open from Server | OPENFROMSERVER command and API calls | Online Demo{target="_blank"} |
| Open from Local Cache | OPENFROMLOCAL command and IndexedDB storage | Online Demo{target="_blank"} |
| Save to Server | SAVESERVER command and incremental save | Online Demo{target="_blank"} |
| Save to Local Cache | SAVELOCAL command and offline storage | Online Demo{target="_blank"} |
| Quick Save Download | QSAVE command downloads webcad file | Online Demo{target="_blank"} |
| Save As | SAVEAS command custom filename download | Online Demo{target="_blank"} |
| Import Local DWG | IMPORTDWG command uploads and converts DWG file | Online Demo{target="_blank"} |
| Export as DWG | EXPORTDWG command exports DWG format | Online Demo{target="_blank"} |
| Export as PNG Image | EXPORTPNG command exports current view as PNG | Online Demo{target="_blank"} |
| Document Diff | Compare two document states with DiffUtils, display in DiffPanel | Online Demo{target="_blank"} |
| New Drawing from Template | TemplateService.openFromTemplate then export DWG | Online Demo{target="_blank"} |
Core API
Open from Server
const { DrawingManagerService } = vjcad;
const drawingManager = new DrawingManagerService();
const result = await drawingManager.openDrawing({
type: 'imports',
mapid: 'drawing-id',
version: 'v1',
branch: 'main',
patchId: 'base',
readOnly: false
});
if (result.success) {
await Engine.view.openDbDoc(result.webcadJson, result.webcadData);
}Save to Server
// Save to server (incremental save)
await Engine.editor.executerWithOp('SAVESERVER');
// Or use API
const result = await drawingManager.saveDrawing({
mapid: 'drawing-id',
version: 'v1',
branch: 'main'
});Local File Operations
// Save to local (download)
await Engine.editor.executerWithOp('QSAVE');
// Save As (custom filename)
await Engine.editor.executerWithOp('SAVEAS');
// Save to local cache (IndexedDB)
await Engine.editor.executerWithOp('SAVELOCAL');
// Open from local cache
await Engine.editor.executerWithOp('OPENFROMLOCAL');DWG Import/Export
// Import DWG (upload and convert)
await Engine.editor.executerWithOp('IMPORTDWG');
// Export as DWG
await Engine.editor.executerWithOp('EXPORTDWG');Export PNG Image
// Export via command (dialog for entity selection, theme color, width)
await Engine.editor.executerWithOp('EXPORTPNG');
// Export via API
const { exportEntitiesToImageAndDownload } = vjcad;
await exportEntitiesToImageAndDownload({
entities: myEntities, // Optional, all entities by default
width: 1920, // Image width, height auto-calculated
theme: 'dark', // 'dark' black background / 'light' white background
fileName: 'drawing.png'
});File Formats
| Format | Description |
|---|---|
.webcad | WebCAD native format (JSON) |
.dwg | AutoCAD format (requires server-side conversion) |
.png / .jpg | View screenshot (frontend-only export) |