@mlightcad/data-model 1.14.14 → 1.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +264 -264
  2. package/dist/data-model.cjs +15 -15
  3. package/lib/base/AcDbDxfFiler.d.ts +5 -0
  4. package/lib/base/AcDbDxfFiler.d.ts.map +1 -1
  5. package/lib/base/AcDbDxfFiler.js +75 -12
  6. package/lib/base/AcDbDxfFiler.js.map +1 -1
  7. package/lib/base/AcDbObject.d.ts +47 -1
  8. package/lib/base/AcDbObject.d.ts.map +1 -1
  9. package/lib/base/AcDbObject.js +323 -37
  10. package/lib/base/AcDbObject.js.map +1 -1
  11. package/lib/converter/worker/AcDbDwgConverterLicense.d.ts +2 -2
  12. package/lib/converter/worker/AcDbDwgConverterLicense.d.ts.map +1 -1
  13. package/lib/converter/worker/AcDbDwgConverterLicense.js +4 -4
  14. package/lib/converter/worker/AcDbDwgConverterLicense.js.map +1 -1
  15. package/lib/database/AcDbDatabase.d.ts.map +1 -1
  16. package/lib/database/AcDbDatabase.js +88 -66
  17. package/lib/database/AcDbDatabase.js.map +1 -1
  18. package/lib/entity/AcDbAttributeDefinition.d.ts +6 -0
  19. package/lib/entity/AcDbAttributeDefinition.d.ts.map +1 -1
  20. package/lib/entity/AcDbAttributeDefinition.js +14 -4
  21. package/lib/entity/AcDbAttributeDefinition.js.map +1 -1
  22. package/lib/entity/AcDbEntity.d.ts.map +1 -1
  23. package/lib/entity/AcDbEntity.js +2 -0
  24. package/lib/entity/AcDbEntity.js.map +1 -1
  25. package/lib/entity/AcDbWipeout.d.ts +7 -6
  26. package/lib/entity/AcDbWipeout.d.ts.map +1 -1
  27. package/lib/entity/AcDbWipeout.js +11 -6
  28. package/lib/entity/AcDbWipeout.js.map +1 -1
  29. package/lib/misc/AcDbImportDynBlockMetadata.d.ts +1 -1
  30. package/lib/misc/AcDbImportDynBlockMetadata.js +1 -1
  31. package/lib/misc/AcDbMemoryEstimator.d.ts.map +1 -1
  32. package/lib/misc/AcDbMemoryEstimator.js +4 -3
  33. package/lib/misc/AcDbMemoryEstimator.js.map +1 -1
  34. package/package.json +5 -5
package/README.md CHANGED
@@ -1,265 +1,265 @@
1
- # @mlightcad/data-model
2
-
3
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
- [![npm version](https://img.shields.io/npm/v/@mlightcad/data-model.svg)](https://www.npmjs.com/package/@mlightcad/data-model)
5
-
6
- The data-model package provides the core classes for interacting with AutoCAD's database and entities. This package mimics AutoCAD ObjectARX's AcDb (Database) classes and implements the drawing database structure that AutoCAD developers are familiar with.
7
-
8
- ## Overview
9
-
10
- This package contains the core classes for defining and manipulating AutoCAD entities (e.g., lines, circles, blocks), handling entity attributes and geometric data, and storing and retrieving data from the drawing database. It uses the same drawing database structure as AutoCAD ObjectARX, making it easier for AutoCAD developers to build applications based on this SDK.
11
-
12
- ## Key Features
13
-
14
- - **Database Management**: Complete AutoCAD database structure with tables and records
15
- - **Entity Support**: All major AutoCAD entity types (lines, circles, polylines, blocks, etc.)
16
- - **File Conversion**: Built-in MIT DXF converter (`AcDbNativeDxfConverter`, registered by default); extensible converter registration for DWG and alternate DXF readers
17
- - **Symbol Tables**: Layer, linetype, text style, and dimension style management
18
- - **Block Management**: Block table and block reference handling
19
- - **Dimension Support**: Comprehensive dimension entity types
20
- - **Layout Management**: Paper space and model space layout handling
21
-
22
- ## Installation
23
-
24
- ```bash
25
- npm install @mlightcad/data-model
26
- ```
27
-
28
- ## Key Classes
29
-
30
- ### Database and Base Classes
31
- - **AcDbDatabase**: Main database class that contains all drawing data
32
- - **AcDbObject**: Base class for all database-resident objects
33
- - **AcDbHostApplicationServices**: Services provided by the host application
34
-
35
- ### Symbol Tables
36
- - **AcDbSymbolTable**: Base class for symbol tables
37
- - **AcDbSymbolTableRecord**: Base class for symbol table records
38
- - **AcDbLayerTable, AcDbLayerTableRecord**: Layer management
39
- - **AcDbLinetypeTable, AcDbLinetypeTableRecord**: Linetype management
40
- - **AcDbTextStyleTable, AcDbTextStyleTableRecord**: Text style management
41
- - **AcDbDimStyleTable, AcDbDimStyleTableRecord**: Dimension style management
42
- - **AcDbBlockTable, AcDbBlockTableRecord**: Block management
43
- - **AcDbViewportTable, AcDbViewportTableRecord**: Viewport management
44
-
45
- ### Entities
46
- - **AcDbEntity**: Base class for all drawable objects
47
- - **AcDbLine**: Line entity
48
- - **AcDbCircle**: Circle entity
49
- - **AcDbArc**: Arc entity
50
- - **AcDbPolyline**: Polyline entity
51
- - **AcDbText, AcDbMText**: Text and multiline text entities
52
- - **AcDbBlockReference**: Block reference entity
53
- - **AcDbPoint**: Point entity
54
- - **AcDbEllipse**: Ellipse entity
55
- - **AcDbSpline**: Spline curve entity
56
- - **AcDbHatch**: Hatch pattern entity
57
- - **AcDbTable**: Table entity
58
- - **AcDbRasterImage**: Raster image entity
59
- - **AcDbLeader**: Leader entity
60
- - **AcDbRay, AcDbXline**: Construction line entities
61
- - **AcDbTrace, AcDbWipeout**: Filled area entities
62
-
63
- ### Dimension Entities
64
- - **AcDbDimension**: Base class for dimension entities
65
- - **AcDbAlignedDimension**: Aligned dimension
66
- - **AcDbRadialDimension**: Radial dimension
67
- - **AcDbDiametricDimension**: Diametric dimension
68
- - **AcDb3PointAngularDimension**: 3-point angular dimension
69
- - **AcDbArcDimension**: Arc dimension
70
- - **AcDbOrdinateDimension**: Ordinate dimension
71
-
72
- ### Objects and Layouts
73
- - **AcDbDictionary**: Dictionary object for storing key-value pairs
74
- - **AcDbRasterImageDef**: Raster image definition
75
- - **AcDbLayout**: Layout object for paper space
76
- - **AcDbLayoutDictionary**: Layout dictionary management
77
- - **AcDbLayoutManager**: Layout manager for switching between layouts
78
-
79
- ### File Conversion
80
- - **AcDbDatabaseConverter**: Base class for file format converters
81
- - **AcDbDatabaseConverterManager**: Manages registered file converters
82
- - **AcDbBatchProcessing**: Batch processing utilities
83
- - **AcDbBaseWorker**, **acdbCreateWorkerApi**: Web Worker infrastructure for parsers
84
-
85
- DXF import is built in via `AcDbNativeDxfConverter` (registered by default). An optional GPL alternative is [@mlightcad/dxf-json-converter](https://github.com/mlightcad/dwg-dxf-converter/tree/main/packages/dxf-json-converter). DWG import is provided by converter packages such as [@mlightcad/libredwg-converter](../libredwg-converter/README.md); register a DWG converter with `AcDbDatabaseConverterManager` before calling `AcDbDatabase.read()` on DWG files.
86
-
87
- ### Utilities
88
- - **AcDbConstants**: Database constants
89
- - **AcDbObjectIterator**: Iterator for database objects
90
- - **AcDbAngleUnits**: Angle unit utilities
91
- - **AcDbUnitsValue**: Unit value handling
92
- - **AcDbOsnapMode**: Object snap modes
93
- - **AcDbRenderingCache**: Rendering cache management
94
-
95
- ## Usage Examples
96
-
97
- ### Database Operations
98
- ```typescript
99
- import { AcDbDatabase } from '@mlightcad/data-model';
100
-
101
- // Create a new database
102
- const database = new AcDbDatabase();
103
-
104
- // Get symbol tables
105
- const layerTable = database.getLayerTable();
106
- const blockTable = database.getBlockTable();
107
- const linetypeTable = database.getLinetypeTable();
108
- ```
109
-
110
- ### Entity Creation
111
- ```typescript
112
- import { AcDbLine, AcDbCircle, AcGePoint3d } from '@mlightcad/data-model';
113
-
114
- // Create a line entity
115
- const startPoint = new AcGePoint3d(0, 0, 0);
116
- const endPoint = new AcGePoint3d(10, 10, 0);
117
- const line = new AcDbLine(startPoint, endPoint);
118
-
119
- // Create a circle entity
120
- const center = new AcGePoint3d(0, 0, 0);
121
- const radius = 5;
122
- const circle = new AcDbCircle(center, radius);
123
-
124
- // Set entity properties
125
- line.setColor(1); // Red
126
- line.setLayer('0');
127
- circle.setLinetype('CONTINUOUS');
128
- ```
129
-
130
- ### Layer Management
131
- ```typescript
132
- import { AcDbLayerTableRecord } from '@mlightcad/data-model';
133
-
134
- // Create a new layer
135
- const layerRecord = new AcDbLayerTableRecord();
136
- layerRecord.setName('MyLayer');
137
- layerRecord.setColor(2); // Yellow
138
- layerRecord.setLinetype('DASHED');
139
-
140
- // Add layer to database
141
- const layerTable = database.getLayerTable();
142
- layerTable.add(layerRecord);
143
- ```
144
-
145
- ### Block Operations
146
- ```typescript
147
- import { AcDbBlockReference, AcGePoint3d } from '@mlightcad/data-model';
148
-
149
- // Create a block reference
150
- const insertionPoint = new AcGePoint3d(0, 0, 0);
151
- const blockRef = new AcDbBlockReference(insertionPoint, 'MyBlock');
152
-
153
- // Set block properties
154
- blockRef.setScale(2.0);
155
- blockRef.setRotation(Math.PI / 4);
156
-
157
- // Add to model space
158
- const modelSpace = database.getModelSpace();
159
- modelSpace.appendEntity(blockRef);
160
- ```
161
-
162
- ### File Conversion
163
-
164
- DXF support is registered by default via `AcDbNativeDxfConverter` (MIT, main-thread
165
- streaming). You only need to register a converter when you want a different DXF
166
- implementation or when reading DWG files.
167
-
168
- ```typescript
169
- import {
170
- AcDbDatabase,
171
- AcDbDatabaseConverterManager,
172
- AcDbFileType,
173
- acdbHostApplicationServices,
174
- AcDbOpenDatabaseOptions
175
- } from '@mlightcad/data-model'
176
- import { AcDbLibreDwgConverter } from '@mlightcad/libredwg-converter'
177
-
178
- // Optional: replace the default native DXF converter (e.g. GPL worker-based parser)
179
- // import { AcDbDxfConverter } from '@mlightcad/dxf-json-converter'
180
- // AcDbDatabaseConverterManager.instance.register(
181
- // AcDbFileType.DXF,
182
- // new AcDbDxfConverter({
183
- // useWorker: true,
184
- // parserWorkerUrl: './assets/dxf-parser-worker.js'
185
- // })
186
- // )
187
-
188
- // DWG still requires an explicit converter registration
189
- AcDbDatabaseConverterManager.instance.register(
190
- AcDbFileType.DWG,
191
- new AcDbLibreDwgConverter({
192
- useWorker: true,
193
- parserWorkerUrl: './assets/libredwg-parser-worker.js'
194
- })
195
- )
196
-
197
- // Read a file into the database
198
- const database = new AcDbDatabase()
199
- acdbHostApplicationServices().workingDatabase = database
200
- const buffer = await file.arrayBuffer()
201
- await database.read(buffer, { readOnly: true }, AcDbFileType.DXF)
202
- ```
203
-
204
- ### Font Loading
205
-
206
- Fonts referenced by text entities are loaded on demand by the mtext renderer when a
207
- font is first needed. Viewers such as `@mlightcad/cad-simple-viewer` typically resolve
208
- font metadata from [mlightcad/cad-data](https://github.com/mlightcad/cad-data)
209
- (default CDN: `https://cdn.jsdelivr.net/gh/mlightcad/cad-data@main/`).
210
-
211
- To self-host fonts and templates (directory layout, `fonts.json`, CORS, and `baseUrl`
212
- configuration), see the
213
- [Self Hosted Fonts and Templates](https://github.com/mlightcad/cad-viewer/wiki/Self-Hosted-Fonts-and-Templates)
214
- guide in the cad-viewer wiki.
215
-
216
- ### Dimension Creation
217
- ```typescript
218
- import { AcDbAlignedDimension, AcGePoint3d } from '@mlightcad/data-model';
219
-
220
- // Create an aligned dimension
221
- const defPoint1 = new AcGePoint3d(0, 0, 0);
222
- const defPoint2 = new AcGePoint3d(10, 0, 0);
223
- const textPosition = new AcGePoint3d(5, 5, 0);
224
-
225
- const dimension = new AcDbAlignedDimension(defPoint1, defPoint2, textPosition);
226
- dimension.setDimensionText('10.0');
227
- dimension.setDimensionStyle('Standard');
228
- ```
229
-
230
- ### Layout Management
231
- ```typescript
232
- import { AcDbLayoutManager } from '@mlightcad/data-model';
233
-
234
- // Get layout manager
235
- const layoutManager = database.getLayoutManager();
236
-
237
- // Get current layout
238
- const currentLayout = layoutManager.getCurrentLayout();
239
-
240
- // Switch to model space
241
- layoutManager.setCurrentLayout('Model');
242
-
243
- // Create a new layout
244
- const newLayout = layoutManager.createLayout('MyLayout');
245
- newLayout.setPlotType('Extents');
246
- newLayout.setPlotCentered(true);
247
- ```
248
-
249
- ## Dependencies
250
-
251
- - **@mlightcad/common**: For common utilities (peer dependency)
252
- - **@mlightcad/geometry-engine**: For geometric operations (peer dependency)
253
- - **@mlightcad/graphic-interface**: For graphics interface (peer dependency)
254
- - **iconv-lite**: For text encoding conversion
255
- - **uid**: For unique ID generation
256
-
257
- DXF reading works out of the box. For DWG, install a converter such as [@mlightcad/libredwg-converter](../libredwg-converter/README.md). An optional GPL DXF alternative is [@mlightcad/dxf-json-converter](https://github.com/mlightcad/dwg-dxf-converter/tree/main/packages/dxf-json-converter).
258
-
259
- ## API Documentation
260
-
261
- For detailed API documentation, visit the [RealDWG-Web documentation](https://mlight-lee.github.io/realdwg-web/).
262
-
263
- ## Contributing
264
-
1
+ # @mlightcad/data-model
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![npm version](https://img.shields.io/npm/v/@mlightcad/data-model.svg)](https://www.npmjs.com/package/@mlightcad/data-model)
5
+
6
+ The data-model package provides the core classes for interacting with AutoCAD's database and entities. This package mimics AutoCAD ObjectARX's AcDb (Database) classes and implements the drawing database structure that AutoCAD developers are familiar with.
7
+
8
+ ## Overview
9
+
10
+ This package contains the core classes for defining and manipulating AutoCAD entities (e.g., lines, circles, blocks), handling entity attributes and geometric data, and storing and retrieving data from the drawing database. It uses the same drawing database structure as AutoCAD ObjectARX, making it easier for AutoCAD developers to build applications based on this SDK.
11
+
12
+ ## Key Features
13
+
14
+ - **Database Management**: Complete AutoCAD database structure with tables and records
15
+ - **Entity Support**: All major AutoCAD entity types (lines, circles, polylines, blocks, etc.)
16
+ - **File Conversion**: Built-in MIT DXF converter (`AcDbNativeDxfConverter`, registered by default); extensible converter registration for DWG and alternate DXF readers
17
+ - **Symbol Tables**: Layer, linetype, text style, and dimension style management
18
+ - **Block Management**: Block table and block reference handling
19
+ - **Dimension Support**: Comprehensive dimension entity types
20
+ - **Layout Management**: Paper space and model space layout handling
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install @mlightcad/data-model
26
+ ```
27
+
28
+ ## Key Classes
29
+
30
+ ### Database and Base Classes
31
+ - **AcDbDatabase**: Main database class that contains all drawing data
32
+ - **AcDbObject**: Base class for all database-resident objects
33
+ - **AcDbHostApplicationServices**: Services provided by the host application
34
+
35
+ ### Symbol Tables
36
+ - **AcDbSymbolTable**: Base class for symbol tables
37
+ - **AcDbSymbolTableRecord**: Base class for symbol table records
38
+ - **AcDbLayerTable, AcDbLayerTableRecord**: Layer management
39
+ - **AcDbLinetypeTable, AcDbLinetypeTableRecord**: Linetype management
40
+ - **AcDbTextStyleTable, AcDbTextStyleTableRecord**: Text style management
41
+ - **AcDbDimStyleTable, AcDbDimStyleTableRecord**: Dimension style management
42
+ - **AcDbBlockTable, AcDbBlockTableRecord**: Block management
43
+ - **AcDbViewportTable, AcDbViewportTableRecord**: Viewport management
44
+
45
+ ### Entities
46
+ - **AcDbEntity**: Base class for all drawable objects
47
+ - **AcDbLine**: Line entity
48
+ - **AcDbCircle**: Circle entity
49
+ - **AcDbArc**: Arc entity
50
+ - **AcDbPolyline**: Polyline entity
51
+ - **AcDbText, AcDbMText**: Text and multiline text entities
52
+ - **AcDbBlockReference**: Block reference entity
53
+ - **AcDbPoint**: Point entity
54
+ - **AcDbEllipse**: Ellipse entity
55
+ - **AcDbSpline**: Spline curve entity
56
+ - **AcDbHatch**: Hatch pattern entity
57
+ - **AcDbTable**: Table entity
58
+ - **AcDbRasterImage**: Raster image entity
59
+ - **AcDbLeader**: Leader entity
60
+ - **AcDbRay, AcDbXline**: Construction line entities
61
+ - **AcDbTrace, AcDbWipeout**: Filled area entities
62
+
63
+ ### Dimension Entities
64
+ - **AcDbDimension**: Base class for dimension entities
65
+ - **AcDbAlignedDimension**: Aligned dimension
66
+ - **AcDbRadialDimension**: Radial dimension
67
+ - **AcDbDiametricDimension**: Diametric dimension
68
+ - **AcDb3PointAngularDimension**: 3-point angular dimension
69
+ - **AcDbArcDimension**: Arc dimension
70
+ - **AcDbOrdinateDimension**: Ordinate dimension
71
+
72
+ ### Objects and Layouts
73
+ - **AcDbDictionary**: Dictionary object for storing key-value pairs
74
+ - **AcDbRasterImageDef**: Raster image definition
75
+ - **AcDbLayout**: Layout object for paper space
76
+ - **AcDbLayoutDictionary**: Layout dictionary management
77
+ - **AcDbLayoutManager**: Layout manager for switching between layouts
78
+
79
+ ### File Conversion
80
+ - **AcDbDatabaseConverter**: Base class for file format converters
81
+ - **AcDbDatabaseConverterManager**: Manages registered file converters
82
+ - **AcDbBatchProcessing**: Batch processing utilities
83
+ - **AcDbBaseWorker**, **acdbCreateWorkerApi**: Web Worker infrastructure for parsers
84
+
85
+ DXF import is built in via `AcDbNativeDxfConverter` (registered by default). An optional GPL alternative is [@mlightcad/dxf-json-converter](https://github.com/mlightcad/dwg-dxf-converter/tree/main/packages/dxf-json-converter). DWG import is provided by converter packages such as [@mlightcad/libredwg-converter](../libredwg-converter/README.md); register a DWG converter with `AcDbDatabaseConverterManager` before calling `AcDbDatabase.read()` on DWG files.
86
+
87
+ ### Utilities
88
+ - **AcDbConstants**: Database constants
89
+ - **AcDbObjectIterator**: Iterator for database objects
90
+ - **AcDbAngleUnits**: Angle unit utilities
91
+ - **AcDbUnitsValue**: Unit value handling
92
+ - **AcDbOsnapMode**: Object snap modes
93
+ - **AcDbRenderingCache**: Rendering cache management
94
+
95
+ ## Usage Examples
96
+
97
+ ### Database Operations
98
+ ```typescript
99
+ import { AcDbDatabase } from '@mlightcad/data-model';
100
+
101
+ // Create a new database
102
+ const database = new AcDbDatabase();
103
+
104
+ // Get symbol tables
105
+ const layerTable = database.getLayerTable();
106
+ const blockTable = database.getBlockTable();
107
+ const linetypeTable = database.getLinetypeTable();
108
+ ```
109
+
110
+ ### Entity Creation
111
+ ```typescript
112
+ import { AcDbLine, AcDbCircle, AcGePoint3d } from '@mlightcad/data-model';
113
+
114
+ // Create a line entity
115
+ const startPoint = new AcGePoint3d(0, 0, 0);
116
+ const endPoint = new AcGePoint3d(10, 10, 0);
117
+ const line = new AcDbLine(startPoint, endPoint);
118
+
119
+ // Create a circle entity
120
+ const center = new AcGePoint3d(0, 0, 0);
121
+ const radius = 5;
122
+ const circle = new AcDbCircle(center, radius);
123
+
124
+ // Set entity properties
125
+ line.setColor(1); // Red
126
+ line.setLayer('0');
127
+ circle.setLinetype('CONTINUOUS');
128
+ ```
129
+
130
+ ### Layer Management
131
+ ```typescript
132
+ import { AcDbLayerTableRecord } from '@mlightcad/data-model';
133
+
134
+ // Create a new layer
135
+ const layerRecord = new AcDbLayerTableRecord();
136
+ layerRecord.setName('MyLayer');
137
+ layerRecord.setColor(2); // Yellow
138
+ layerRecord.setLinetype('DASHED');
139
+
140
+ // Add layer to database
141
+ const layerTable = database.getLayerTable();
142
+ layerTable.add(layerRecord);
143
+ ```
144
+
145
+ ### Block Operations
146
+ ```typescript
147
+ import { AcDbBlockReference, AcGePoint3d } from '@mlightcad/data-model';
148
+
149
+ // Create a block reference
150
+ const insertionPoint = new AcGePoint3d(0, 0, 0);
151
+ const blockRef = new AcDbBlockReference(insertionPoint, 'MyBlock');
152
+
153
+ // Set block properties
154
+ blockRef.setScale(2.0);
155
+ blockRef.setRotation(Math.PI / 4);
156
+
157
+ // Add to model space
158
+ const modelSpace = database.getModelSpace();
159
+ modelSpace.appendEntity(blockRef);
160
+ ```
161
+
162
+ ### File Conversion
163
+
164
+ DXF support is registered by default via `AcDbNativeDxfConverter` (MIT, main-thread
165
+ streaming). You only need to register a converter when you want a different DXF
166
+ implementation or when reading DWG files.
167
+
168
+ ```typescript
169
+ import {
170
+ AcDbDatabase,
171
+ AcDbDatabaseConverterManager,
172
+ AcDbFileType,
173
+ acdbHostApplicationServices,
174
+ AcDbOpenDatabaseOptions
175
+ } from '@mlightcad/data-model'
176
+ import { AcDbLibreDwgConverter } from '@mlightcad/libredwg-converter'
177
+
178
+ // Optional: replace the default native DXF converter (e.g. GPL worker-based parser)
179
+ // import { AcDbDxfConverter } from '@mlightcad/dxf-json-converter'
180
+ // AcDbDatabaseConverterManager.instance.register(
181
+ // AcDbFileType.DXF,
182
+ // new AcDbDxfConverter({
183
+ // useWorker: true,
184
+ // parserWorkerUrl: './assets/dxf-parser-worker.js'
185
+ // })
186
+ // )
187
+
188
+ // DWG still requires an explicit converter registration
189
+ AcDbDatabaseConverterManager.instance.register(
190
+ AcDbFileType.DWG,
191
+ new AcDbLibreDwgConverter({
192
+ useWorker: true,
193
+ parserWorkerUrl: './assets/libredwg-parser-worker.js'
194
+ })
195
+ )
196
+
197
+ // Read a file into the database
198
+ const database = new AcDbDatabase()
199
+ acdbHostApplicationServices().workingDatabase = database
200
+ const buffer = await file.arrayBuffer()
201
+ await database.read(buffer, { readOnly: true }, AcDbFileType.DXF)
202
+ ```
203
+
204
+ ### Font Loading
205
+
206
+ Fonts referenced by text entities are loaded on demand by the mtext renderer when a
207
+ font is first needed. Viewers such as `@mlightcad/cad-simple-viewer` typically resolve
208
+ font metadata from [mlightcad/cad-data](https://github.com/mlightcad/cad-data)
209
+ (default CDN: `https://cdn.jsdelivr.net/gh/mlightcad/cad-data@main/`).
210
+
211
+ To self-host fonts and templates (directory layout, `fonts.json`, CORS, and `baseUrl`
212
+ configuration), see the
213
+ [Self Hosted Fonts and Templates](https://github.com/mlightcad/cad-viewer/wiki/Self-Hosted-Fonts-and-Templates)
214
+ guide in the cad-viewer wiki.
215
+
216
+ ### Dimension Creation
217
+ ```typescript
218
+ import { AcDbAlignedDimension, AcGePoint3d } from '@mlightcad/data-model';
219
+
220
+ // Create an aligned dimension
221
+ const defPoint1 = new AcGePoint3d(0, 0, 0);
222
+ const defPoint2 = new AcGePoint3d(10, 0, 0);
223
+ const textPosition = new AcGePoint3d(5, 5, 0);
224
+
225
+ const dimension = new AcDbAlignedDimension(defPoint1, defPoint2, textPosition);
226
+ dimension.setDimensionText('10.0');
227
+ dimension.setDimensionStyle('Standard');
228
+ ```
229
+
230
+ ### Layout Management
231
+ ```typescript
232
+ import { AcDbLayoutManager } from '@mlightcad/data-model';
233
+
234
+ // Get layout manager
235
+ const layoutManager = database.getLayoutManager();
236
+
237
+ // Get current layout
238
+ const currentLayout = layoutManager.getCurrentLayout();
239
+
240
+ // Switch to model space
241
+ layoutManager.setCurrentLayout('Model');
242
+
243
+ // Create a new layout
244
+ const newLayout = layoutManager.createLayout('MyLayout');
245
+ newLayout.setPlotType('Extents');
246
+ newLayout.setPlotCentered(true);
247
+ ```
248
+
249
+ ## Dependencies
250
+
251
+ - **@mlightcad/common**: For common utilities (peer dependency)
252
+ - **@mlightcad/geometry-engine**: For geometric operations (peer dependency)
253
+ - **@mlightcad/graphic-interface**: For graphics interface (peer dependency)
254
+ - **iconv-lite**: For text encoding conversion
255
+ - **uid**: For unique ID generation
256
+
257
+ DXF reading works out of the box. For DWG, install a converter such as [@mlightcad/libredwg-converter](../libredwg-converter/README.md). An optional GPL DXF alternative is [@mlightcad/dxf-json-converter](https://github.com/mlightcad/dwg-dxf-converter/tree/main/packages/dxf-json-converter).
258
+
259
+ ## API Documentation
260
+
261
+ For detailed API documentation, visit the [RealDWG-Web documentation](https://mlight-lee.github.io/realdwg-web/).
262
+
263
+ ## Contributing
264
+
265
265
  This package is part of the RealDWG-Web monorepo. Please refer to the main project README for contribution guidelines.