@mlightcad/libredwg-web 0.7.7 → 0.7.8

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 (49) hide show
  1. package/dist/libredwg-web.js +194 -5
  2. package/dist/libredwg-web.umd.cjs +194 -5
  3. package/lib/converter/converter.d.ts +3 -0
  4. package/lib/converter/converter.js +76 -1
  5. package/lib/converter/entityConverter.d.ts +1 -0
  6. package/lib/converter/entityConverter.js +53 -5
  7. package/lib/converter/mleaderColorCodec.d.ts +9 -0
  8. package/lib/converter/mleaderColorCodec.js +52 -0
  9. package/lib/converter/stringConverter.d.ts +3 -0
  10. package/lib/converter/stringConverter.js +7 -0
  11. package/lib/converter/utils.d.ts +21 -0
  12. package/lib/converter/utils.js +27 -0
  13. package/lib/database/database.d.ts +4 -1
  14. package/lib/database/entities/index.d.ts +1 -0
  15. package/lib/database/entities/index.js +1 -0
  16. package/lib/database/entities/solid3d.d.ts +32 -0
  17. package/lib/database/entities/solid3d.js +2 -0
  18. package/lib/database/entities/unknown.d.ts +7 -0
  19. package/lib/database/entities/unknown.js +2 -0
  20. package/lib/database/objects/index.d.ts +3 -0
  21. package/lib/database/objects/index.js +3 -0
  22. package/lib/database/objects/layerFilter.d.ts +12 -0
  23. package/lib/database/objects/layerFilter.js +2 -0
  24. package/lib/database/objects/layerIndex.d.ts +18 -0
  25. package/lib/database/objects/layerIndex.js +2 -0
  26. package/lib/database/objects/unknown.d.ts +7 -0
  27. package/lib/database/objects/unknown.js +2 -0
  28. package/lib/database/objects/xrecord.d.ts +30 -0
  29. package/lib/database/objects/xrecord.js +2 -0
  30. package/lib/debug.d.ts +13 -0
  31. package/lib/debug.js +48 -0
  32. package/lib/libredwg-core.d.ts +740 -0
  33. package/lib/libredwg-core.js +1121 -0
  34. package/lib/libredwg-web.d.ts +3 -0
  35. package/lib/libredwg-web.js +2318 -0
  36. package/lib/libredwg.d.ts +30 -1
  37. package/lib/libredwg.js +44 -0
  38. package/lib/memory64/index.d.ts +4 -0
  39. package/lib/memory64/index.js +4 -0
  40. package/lib/memory64/libredwg.d.ts +13 -0
  41. package/lib/memory64/libredwg.js +23 -0
  42. package/lib/types/common.d.ts +2 -0
  43. package/lib/utils/common.d.ts +4 -0
  44. package/lib/utils/common.js +12 -0
  45. package/lib/utils/index.d.ts +2 -0
  46. package/lib/utils/index.js +2 -0
  47. package/package.json +2 -2
  48. package/wasm/libredwg-web.d.ts +548 -544
  49. package/wasm/libredwg-web.wasm +0 -0
@@ -0,0 +1,1121 @@
1
+ import { LibreDwgConverter } from './converter';
2
+ import { dwgCodePageToEncoding, dwgVersions } from './database';
3
+ import { SvgConverter } from './svg';
4
+ import { Dwg_Error, Dwg_File_Type, Dwg_Object_Type } from './types';
5
+ export var DwgThumbnailImageType;
6
+ (function (DwgThumbnailImageType) {
7
+ DwgThumbnailImageType[DwgThumbnailImageType["BMP"] = 2] = "BMP";
8
+ DwgThumbnailImageType[DwgThumbnailImageType["WMF"] = 3] = "WMF";
9
+ DwgThumbnailImageType[DwgThumbnailImageType["PNG"] = 6] = "PNG";
10
+ })(DwgThumbnailImageType || (DwgThumbnailImageType = {}));
11
+ export class LibreDwgCore {
12
+ wasmInstance;
13
+ decoder;
14
+ constructor(wasmInstance) {
15
+ this.wasmInstance = wasmInstance;
16
+ return new Proxy(this, {
17
+ get: (target, prop, receiver) => {
18
+ if (prop in target) {
19
+ return Reflect.get(target, prop, receiver);
20
+ }
21
+ // Delegate to the wasmInstance for WebAssembly methods
22
+ return Reflect.get(target.wasmInstance, prop, receiver);
23
+ }
24
+ });
25
+ }
26
+ dwg_read_data(fileContent, fileType) {
27
+ if (fileType == Dwg_File_Type.DWG) {
28
+ const fileName = 'tmp.dwg';
29
+ try {
30
+ this.wasmInstance.FS.writeFile(fileName, new Uint8Array(fileContent));
31
+ let result;
32
+ try {
33
+ result = this.wasmInstance.dwg_read_file(fileName);
34
+ }
35
+ catch (err) {
36
+ if (err instanceof Error &&
37
+ /memory access out of bounds|RuntimeError/.test(err.message)) {
38
+ throw new Error('Failed to decode DWG: WASM memory limit exceeded. Large drawings ' +
39
+ '(many objects/handles) can need several GB while decoding; ' +
40
+ '32-bit WASM is capped at 4 GB. Try a smaller file, convert ' +
41
+ 'with native dwgread/dxf on the server, or use the Memory64 build ' +
42
+ '(@mlightcad/libredwg-web/memory64; Chrome 133+).');
43
+ }
44
+ throw err;
45
+ }
46
+ if (result.error & Dwg_Error.OUTOFMEM) {
47
+ this.wasmInstance.dwg_abandon(result.data);
48
+ throw new Error('Failed to decode DWG: out of WASM memory. Rebuild with pnpm build:wasm:32 (INITIAL_MEMORY=1GB) or use a smaller file.');
49
+ }
50
+ if (result.error != 0) {
51
+ console.warn('Open dwg file with error code:', result.error);
52
+ }
53
+ return result.data;
54
+ }
55
+ finally {
56
+ if (this.wasmInstance.FS.analyzePath(fileName, false).exists) {
57
+ this.wasmInstance.FS.unlink(fileName);
58
+ }
59
+ }
60
+ }
61
+ // else if (fileType == Dwg_File_Type.DXF) {
62
+ // const fileName = "tmp.dxf";
63
+ // this.wasmInstance.FS.writeFile(fileName, new Uint8Array(fileContent as ArrayBuffer));
64
+ // const result = this.wasmInstance.dxf_read_file(fileName);
65
+ // if (result.error != 0) {
66
+ // console.log('Open dxf file with error code: ', result.error);
67
+ // }
68
+ // this.wasmInstance.FS.unlink(fileName);
69
+ // return result.data as Dwg_Data_Ptr;
70
+ // }
71
+ }
72
+ /**
73
+ * Converts DWG file content to DXF file content.
74
+ * @param fileContent DWG file content.
75
+ * @returns Returns DXF file content if conversion succeeds. Otherwise returns null.
76
+ */
77
+ dwg_write_dxf(fileContent) {
78
+ const inputFileName = 'tmp.dwg';
79
+ const outputFileName = 'tmp.dxf';
80
+ try {
81
+ this.wasmInstance.FS.writeFile(inputFileName, new Uint8Array(fileContent));
82
+ const error = this.wasmInstance.dwg_write_dxf(inputFileName, outputFileName);
83
+ if (error != 0) {
84
+ console.log('Convert dwg to dxf with error code: ', error);
85
+ return null;
86
+ }
87
+ return this.wasmInstance.FS.readFile(outputFileName);
88
+ }
89
+ finally {
90
+ if (this.wasmInstance.FS.analyzePath(inputFileName, false).exists) {
91
+ this.wasmInstance.FS.unlink(inputFileName);
92
+ }
93
+ if (this.wasmInstance.FS.analyzePath(outputFileName, false).exists) {
94
+ this.wasmInstance.FS.unlink(outputFileName);
95
+ }
96
+ }
97
+ }
98
+ /**
99
+ * Gets the version of the dwg.
100
+ * @param data Pointer to Dwg_Data instance.
101
+ * @returns Return the version of the dwg
102
+ */
103
+ dwg_get_version_type(data) {
104
+ const version = this.wasmInstance.dwg_get_version_type(data);
105
+ return dwgVersions[version];
106
+ }
107
+ /**
108
+ * Gets code page of the dwg.
109
+ * @param data Pointer to Dwg_Data instance.
110
+ * @returns Return code page of the dwg
111
+ */
112
+ dwg_get_codepage(data) {
113
+ const codepage = this.wasmInstance.dwg_get_codepage(data);
114
+ return codepage;
115
+ }
116
+ /**
117
+ * Extracts thumbnail image from dwg.
118
+ * @param data Pointer to Dwg_Data instance.
119
+ * @returns Return thumbnail image data
120
+ */
121
+ dwg_bmp(data) {
122
+ return this.wasmInstance.dwg_bmp(data);
123
+ }
124
+ /**
125
+ * Returns the number of classes in dwg file.
126
+ * @param data Pointer to Dwg_Data instance.
127
+ * @returns Returns the number of classes in dwg file.
128
+ */
129
+ dwg_get_num_classes(data) {
130
+ return this.wasmInstance.dwg_get_num_classes(data);
131
+ }
132
+ /**
133
+ * Returns the nth class in dwg file.
134
+ * @param data Pointer to Dwg_Data instance.
135
+ * @param index Index of the class
136
+ * @returns Returns the nth class in dwg file.
137
+ */
138
+ dwg_get_class(data, index) {
139
+ return this.wasmInstance.dwg_get_class(data, index);
140
+ }
141
+ /**
142
+ * Converts Dwg_Data instance to DwgDatabase instance. DwgDatabase instance doesn't depend on
143
+ * Dwg_Data instance any more after conversion. So you can call function dwg_free to free memory
144
+ * occupied by Dwg_Data.
145
+ * @param data Pointer to Dwg_Data instance.
146
+ * @returns Returns the converted DwgDatabase.
147
+ */
148
+ convert(data) {
149
+ const codepage = this.dwg_get_codepage(data);
150
+ const encoding = dwgCodePageToEncoding(codepage);
151
+ this.decoder = new TextDecoder(encoding);
152
+ const converter = new LibreDwgConverter(this);
153
+ return converter.convert(data);
154
+ }
155
+ /**
156
+ * Converts Dwg_Data instance to DwgDatabase instance and returns conversion statistics.
157
+ * DwgDatabase instance doesn't depend on Dwg_Data instance any more after conversion.
158
+ * So you can call function dwg_free to free memory occupied by Dwg_Data.
159
+ * @param data Pointer to Dwg_Data instance.
160
+ * @returns Returns the converted DwgDatabase and conversion statistics.
161
+ */
162
+ convertEx(data) {
163
+ const codepage = this.dwg_get_codepage(data);
164
+ const encoding = dwgCodePageToEncoding(codepage);
165
+ this.decoder = new TextDecoder(encoding);
166
+ const converter = new LibreDwgConverter(this);
167
+ return {
168
+ database: converter.convert(data),
169
+ stats: converter.getConversionStats()
170
+ };
171
+ }
172
+ /**
173
+ * Converts DwgDatabase instance to svg string.
174
+ * @param data DwgDatabase instance.
175
+ * @returns Returns the converted svg string.
176
+ */
177
+ dwg_to_svg(data) {
178
+ const converter = new SvgConverter();
179
+ return converter.convert(data);
180
+ }
181
+ /**
182
+ * Frees the whole DWG. all tables, sections, objects, ...
183
+ * @param data Pointer to Dwg_Data instance.
184
+ */
185
+ dwg_free(data) {
186
+ if (!data) {
187
+ return;
188
+ }
189
+ try {
190
+ this.wasmInstance.dwg_free(data);
191
+ }
192
+ catch {
193
+ try {
194
+ this.wasmInstance.dwg_abandon(data);
195
+ }
196
+ catch {
197
+ // best effort; wasm heap may already be corrupt
198
+ }
199
+ }
200
+ }
201
+ /**
202
+ * Frees the object (all three structs and its fields)
203
+ * @group Dwg_Object Methods
204
+ * @param ptr Pointer to one Dwg_Object instance.
205
+ */
206
+ dwg_free_object(obj_ptr) {
207
+ this.wasmInstance.dwg_free_object(obj_ptr);
208
+ }
209
+ /**
210
+ * Gets an object by its handle.
211
+ * @group Handle Conversion Methods
212
+ * @param data Pointer to Dwg_Data instance.
213
+ * @param ref_ptr Pointer to Dwg_Object_Ref instance.
214
+ * @returns Returns the object whose handle is equal to the given handle.
215
+ */
216
+ dwg_ref_object(data, ref_ptr) {
217
+ return this.wasmInstance.dwg_ref_object(data, ref_ptr);
218
+ }
219
+ /**
220
+ * Gets an object by its handle without warning message.
221
+ * @group Handle Conversion Methods
222
+ * @param data Pointer to Dwg_Data instance.
223
+ * @param ref_ptr Pointer to Dwg_Object_Ref instance.
224
+ * @returns Returns the object whose handle is equal to the given handle.
225
+ */
226
+ dwg_ref_object_silent(data, ref_ptr) {
227
+ return this.wasmInstance.dwg_ref_object_silent(data, ref_ptr);
228
+ }
229
+ /**
230
+ * Gets an object given its handle and relative base object.
231
+ * @group Handle Conversion Methods
232
+ * @param data Pointer to Dwg_Data instance.
233
+ * @param ref_ptr Pointer to Dwg_Object_Ref instance.
234
+ * @param obj_ptr Pointer to the relative base object (Dwg_Object instance).
235
+ * @returns Returns the object given its handle and relative base object.
236
+ */
237
+ dwg_ref_object_relative(data, ref_ptr, obj_ptr) {
238
+ return this.wasmInstance.dwg_ref_object_relative(data, ref_ptr, obj_ptr);
239
+ }
240
+ /**
241
+ * Resolves handle absref value to Dwg_Object instance.
242
+ * @group Handle Conversion Methods
243
+ * @param data Pointer to Dwg_Data instance.
244
+ * @param absref Handle absref value.
245
+ * @returns Returns the object with the given handle absref value.
246
+ */
247
+ dwg_resolve_handle(data, absref) {
248
+ return this.wasmInstance.dwg_resolve_handle(data, absref);
249
+ }
250
+ /**
251
+ * Resolves handle absref value to Dwg_Object instance without warning message.
252
+ * @group Handle Conversion Methods
253
+ * @param data Pointer to Dwg_Data instance.
254
+ * @param absref Handle absref value.
255
+ * @returns Returns the object with the given handle absref value.
256
+ */
257
+ dwg_resolve_handle_silent(data, absref) {
258
+ return this.wasmInstance.dwg_resolve_handle_silent(data, absref);
259
+ }
260
+ /**
261
+ * Sets ref->absolute_ref from the specified obj for a subsequent dwg_resolve_handle
262
+ * @group Handle Conversion Methods
263
+ * @param ref_ptr Pointer to Dwg_Object_Ref instance.
264
+ * @param obj_ptr Pointer to Dwg_Object instance.
265
+ * @returns Returns 1 if set absref value correctly. Otherwise, return 0.
266
+ */
267
+ dwg_resolve_handleref(ref_ptr, obj_ptr) {
268
+ return this.wasmInstance.dwg_resolve_handleref(ref_ptr, obj_ptr);
269
+ }
270
+ /**
271
+ * Returns object (such as line type, layer name, dimension style, and etc.) name by its handle.
272
+ * @group Handle Conversion Methods
273
+ * @param ref_ptr Pointer to Dwg_Object_Ref instance.
274
+ * @returns Returns object name by its handle.
275
+ */
276
+ dwg_ref_get_object_name(ref_ptr) {
277
+ const wasmInstance = this.wasmInstance;
278
+ const obj = wasmInstance.dwg_ref_get_object(ref_ptr);
279
+ const obj_tio = wasmInstance.dwg_object_to_object_tio(obj);
280
+ const obj_name = this.dwg_dynapi_entity_value(obj_tio, 'name')
281
+ .data;
282
+ return obj_name;
283
+ }
284
+ /**
285
+ * Converts Dwg_Object_Object instance to Dwg_Object instance.
286
+ * @group Object Conversion Methods
287
+ * @param obj_ptr Pointer to Dwg_Object_Object instance.
288
+ * @returns Returns one pointer to Dwg_Object instance.
289
+ */
290
+ dwg_obj_obj_to_object(obj_obj_ptr) {
291
+ return this.wasmInstance.dwg_obj_obj_to_object(obj_obj_ptr);
292
+ }
293
+ /**
294
+ * Converts Dwg_Object_* instance to Dwg_Object instance.
295
+ * @group Object Conversion Methods
296
+ * @param obj_generic_ptr Pointer to Dwg_Object_* instance.
297
+ * @returns Returns one pointer to Dwg_Object instance.
298
+ */
299
+ dwg_obj_generic_to_object(obj_generic_ptr) {
300
+ return this.wasmInstance.dwg_obj_generic_to_object(obj_generic_ptr);
301
+ }
302
+ /**
303
+ * Converts Dwg_Object instance to Dwg_Object_Object instance.
304
+ * @group Object Conversion Methods
305
+ * @param obj_ptr Pointer to Dwg_Object instance.
306
+ * @returns Returns one pointer to Dwg_Object_Object instance.
307
+ */
308
+ dwg_object_to_object(obj_ptr) {
309
+ return this.wasmInstance.dwg_object_to_object(obj_ptr);
310
+ }
311
+ /**
312
+ * Gets Dwg_Object_* instance (such as Dwg_Entity_LAYER, Dwg_Entity_STYLE, and etc.)
313
+ * from Dwg_Object instance.
314
+ * @group Object Conversion Methods
315
+ * @param obj_ptr Pointer to Dwg_Object instance.
316
+ * @returns Returns one pointer to Dwg_Object_Object_TIO_Ptr instance.
317
+ */
318
+ dwg_object_to_object_tio(obj_ptr) {
319
+ return this.wasmInstance.dwg_object_to_object_tio(obj_ptr);
320
+ }
321
+ /**
322
+ * Converts Dwg_Object instance to Dwg_Object_Entity instance.
323
+ * @group Object Conversion Methods
324
+ * @param obj_ptr Pointer to Dwg_Object instance.
325
+ * @returns Returns one pointer to Dwg_Object_Entity instance.
326
+ */
327
+ dwg_object_to_entity(obj_ptr) {
328
+ return this.wasmInstance.dwg_object_to_entity(obj_ptr);
329
+ }
330
+ /**
331
+ * Gets Dwg_Entity_* instance (such as Dwg_Entity_LINE, Dwg_Entity_SPLINE, and etc.)
332
+ * from Dwg_Object instance.
333
+ * @group Object Conversion Methods
334
+ * @param obj_ptr Pointer to Dwg_Object instance.
335
+ * @returns Returns one pointer to Dwg_Object_Object_TIO_Ptr instance.
336
+ */
337
+ dwg_object_to_entity_tio(obj_ptr) {
338
+ return this.wasmInstance.dwg_object_to_entity_tio(obj_ptr);
339
+ }
340
+ /**
341
+ * Returns all of entities in the model space. Each item in returned array
342
+ * is one Dwg_Object pointer (Dwg_Object*).
343
+ * @group GetAll Methods
344
+ * @param data Pointer to Dwg_Data instance.
345
+ * @returns Returns all of entities in the model space.
346
+ */
347
+ dwg_getall_entities_in_model_space(data) {
348
+ const wasmInstance = this.wasmInstance;
349
+ const model_space = wasmInstance.dwg_model_space_object(data);
350
+ const entities = [];
351
+ let next = wasmInstance.get_first_owned_entity(model_space);
352
+ while (next) {
353
+ entities.push(next);
354
+ next = wasmInstance.get_next_owned_entity(model_space, next);
355
+ }
356
+ return entities;
357
+ }
358
+ /**
359
+ * Returns all of objects in Dwg_Data instance with the specified type.
360
+ * @group GetAll Methods
361
+ * @param data Pointer to Dwg_Data instance.
362
+ * @param type Object type.
363
+ * @returns Returns all of objects with the specified type.
364
+ */
365
+ dwg_getall_object_by_type(data, type) {
366
+ const wasmInstance = this.wasmInstance;
367
+ const num_objects = wasmInstance.dwg_get_num_objects(data);
368
+ const results = [];
369
+ for (let i = 0; i < num_objects; i++) {
370
+ const obj = wasmInstance.dwg_get_object(data, i);
371
+ const tio = wasmInstance.dwg_object_to_object_tio(obj);
372
+ if (tio && wasmInstance.dwg_object_get_fixedtype(obj) == type) {
373
+ results.push(tio);
374
+ }
375
+ }
376
+ return results;
377
+ }
378
+ /**
379
+ * Returns all of objects in Dwg_Data instance with the specified type.
380
+ * @group GetAll Methods
381
+ * @param data Pointer to Dwg_Data instance.
382
+ * @param type Object type.
383
+ * @returns Returns all of objects with the specified type.
384
+ */
385
+ dwg_getall_entity_by_type(data, type) {
386
+ const wasmInstance = this.wasmInstance;
387
+ const num_objects = wasmInstance.dwg_get_num_objects(data);
388
+ const results = [];
389
+ for (let i = 0; i < num_objects; i++) {
390
+ const obj = wasmInstance.dwg_get_object(data, i);
391
+ const tio = wasmInstance.dwg_object_to_entity_tio(obj);
392
+ if (tio && wasmInstance.dwg_object_get_fixedtype(obj) == type) {
393
+ results.push(tio);
394
+ }
395
+ }
396
+ return results;
397
+ }
398
+ /**
399
+ * Returns all of layer objects in Dwg_Data instance.
400
+ * @group GetAll Methods
401
+ * @param data Pointer to Dwg_Data instance.
402
+ * @returns Returns all of layer objects in Dwg_Data instance.
403
+ */
404
+ dwg_getall_LAYER(data) {
405
+ return this.dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_LAYER);
406
+ }
407
+ /**
408
+ * Returns all of line type objects in Dwg_Data instance.
409
+ * @group GetAll Methods
410
+ * @param data Pointer to Dwg_Data instance.
411
+ * @returns Returns all of line type objects in Dwg_Data instance.
412
+ */
413
+ dwg_getall_LTYPE(data) {
414
+ return this.dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_LTYPE);
415
+ }
416
+ /**
417
+ * Returns all of text style objects in Dwg_Data instance.
418
+ * @group GetAll Methods
419
+ * @param data Pointer to Dwg_Data instance.
420
+ * @returns Returns all of text style objects in Dwg_Data instance.
421
+ */
422
+ dwg_getall_STYLE(data) {
423
+ return this.dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_STYLE);
424
+ }
425
+ /**
426
+ * Returns all of dimension style objects in Dwg_Data instance.
427
+ * @group GetAll Methods
428
+ * @param data Pointer to Dwg_Data instance.
429
+ * @returns Returns all of dimension style objects in Dwg_Data instance.
430
+ */
431
+ dwg_getall_DIMSTYLE(data) {
432
+ return this.dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_DIMSTYLE);
433
+ }
434
+ /**
435
+ * Returns all of viewport objects in Dwg_Data instance.
436
+ * @group GetAll Methods
437
+ * @param data Pointer to Dwg_Data instance.
438
+ * @returns Returns all of viewport objects in Dwg_Data instance.
439
+ */
440
+ dwg_getall_VPORT(data) {
441
+ return this.dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_VPORT);
442
+ }
443
+ /**
444
+ * Returns all of layout objects in Dwg_Data instance.
445
+ * @group GetAll Methods
446
+ * @param data Pointer to Dwg_Data instance.
447
+ * @returns Returns all of layout objects in Dwg_Data instance.
448
+ */
449
+ dwg_getall_LAYOUT(data) {
450
+ return this.dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_LAYOUT);
451
+ }
452
+ /**
453
+ * Returns all of block objects in Dwg_Data instance.
454
+ * @group GetAll Methods
455
+ * @param data Pointer to Dwg_Data instance.
456
+ * @returns Returns all of block objects in Dwg_Data instance.
457
+ */
458
+ dwg_getall_BLOCK(data) {
459
+ return this.dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_BLOCK);
460
+ }
461
+ /**
462
+ * Returns all of block header objects in Dwg_Data instance.
463
+ * @group GetAll Methods
464
+ * @param data Pointer to Dwg_Data instance.
465
+ * @returns Returns all of block header objects in Dwg_Data instance.
466
+ */
467
+ dwg_getall_BLOCK_HEADER(data) {
468
+ return this.dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_BLOCK_HEADER);
469
+ }
470
+ /**
471
+ * Returns all of image definition objects in Dwg_Data instance.
472
+ * @group GetAll Methods
473
+ * @param data Pointer to Dwg_Data instance.
474
+ * @returns Returns all of image definition objects in Dwg_Data instance.
475
+ */
476
+ dwg_getall_IMAGEDEF(data) {
477
+ return this.dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_IMAGEDEF);
478
+ }
479
+ /**
480
+ * Returns all of 2d vertex objects in Dwg_Data instance.
481
+ * @group GetAll Methods
482
+ * @param data Pointer to Dwg_Data instance.
483
+ * @returns Returns all of 2d vertex objects in Dwg_Data instance.
484
+ */
485
+ dwg_getall_VERTEX_2D(data) {
486
+ return this.dwg_getall_entity_by_type(data, Dwg_Object_Type.DWG_TYPE_VERTEX_2D);
487
+ }
488
+ /**
489
+ * Returns all of 3d vertex objects in Dwg_Data instance.
490
+ * @group GetAll Methods
491
+ * @param data Pointer to Dwg_Data instance.
492
+ * @returns Returns all of 3d vertex objects in Dwg_Data instance.
493
+ */
494
+ dwg_getall_VERTEX_3D(data) {
495
+ return this.dwg_getall_entity_by_type(data, Dwg_Object_Type.DWG_TYPE_VERTEX_3D);
496
+ }
497
+ /**
498
+ * Returns all of 2d polyline entities in Dwg_Data instance.
499
+ * @group GetAll Methods
500
+ * @param data Pointer to Dwg_Data instance.
501
+ * @returns Returns all of 2d polyline entities in Dwg_Data instance.
502
+ */
503
+ dwg_getall_POLYLINE_2D(data) {
504
+ return this.dwg_getall_entity_by_type(data, Dwg_Object_Type.DWG_TYPE_POLYLINE_2D);
505
+ }
506
+ /**
507
+ * Returns all of 3d polyline entities in Dwg_Data instance.
508
+ * @group GetAll Methods
509
+ * @param data Pointer to Dwg_Data instance.
510
+ * @returns Returns all of 3d polyline entities in Dwg_Data instance.
511
+ */
512
+ dwg_getall_POLYLINE_3D(data) {
513
+ return this.dwg_getall_entity_by_type(data, Dwg_Object_Type.DWG_TYPE_POLYLINE_3D);
514
+ }
515
+ /**
516
+ * Returns all of image entities in Dwg_Data instance.
517
+ * @group GetAll Methods
518
+ * @param data Pointer to Dwg_Data instance.
519
+ * @returns Returns all of image entities in Dwg_Data instance.
520
+ */
521
+ dwg_getall_IMAGE(data) {
522
+ return this.dwg_getall_entity_by_type(data, Dwg_Object_Type.DWG_TYPE_IMAGE);
523
+ }
524
+ /**
525
+ * Returns all of lwpolyline entities in Dwg_Data instance.
526
+ * @group GetAll Methods
527
+ * @param data Pointer to Dwg_Data instance.
528
+ * @returns Returns all of lwpolyline entities in Dwg_Data instance.
529
+ */
530
+ dwg_getall_LWPOLYLINE(data) {
531
+ return this.dwg_getall_entity_by_type(data, Dwg_Object_Type.DWG_TYPE_LWPOLYLINE);
532
+ }
533
+ /**
534
+ * Converts one C++ handle array to one JavaScript Dwg_Object_Ref array.
535
+ * @group Array Methods
536
+ * @param ptr Pointer to C++ handle array.
537
+ * @param size The size of C++ handle array.
538
+ * @returns Returns one JavaScript Dwg_Object_Ref array from the specified C++ handle array.
539
+ */
540
+ dwg_ptr_to_object_ref_array(ptr, size) {
541
+ return this.wasmInstance.dwg_ptr_to_object_ref_array(ptr, size);
542
+ }
543
+ /**
544
+ * Converts one C++ handle array to one JavaScript Dwg_Object_Ref_Ptr array.
545
+ * @group Array Methods
546
+ * @param ptr Pointer to C++ handle array.
547
+ * @param size The size of C++ handle array.
548
+ * @returns Returns one JavaScript Dwg_Object_Ref_Ptr array from the specified C++ handle array.
549
+ */
550
+ dwg_ptr_to_object_ref_ptr_array(ptr, size) {
551
+ return this.wasmInstance.dwg_ptr_to_object_ref_ptr_array(ptr, size);
552
+ }
553
+ /**
554
+ * Converts one C++ wchar_t* array to one JavaScript string array.
555
+ * @group Array Methods
556
+ * @param ptr Pointer to C++ wchar_t* array.
557
+ * @param size The size of C++ wchar_t* array.
558
+ * @returns Returns one JavaScript string array from the specified C++ wchar_t* array.
559
+ */
560
+ dwg_ptr_to_wchar_string_array(ptr, size) {
561
+ // const array = this.wasmInstance.dwg_ptr_to_char_string_array(ptr, size) as Array<Dwg_String>
562
+ // return array.map(item => item.data)
563
+ return this.wasmInstance.dwg_ptr_to_wchar_string_array(ptr, size);
564
+ }
565
+ /**
566
+ * Converts one C++ unsigned char array to one JavaScript number array.
567
+ * @group Array Methods
568
+ * @param ptr Pointer to C++ unsigned char array.
569
+ * @param size The size of C++ unsigned char array.
570
+ * @returns Returns one JavaScript number array from the specified C++ unsigned char array.
571
+ */
572
+ dwg_ptr_to_unsigned_char_array(ptr, size) {
573
+ return this.wasmInstance.dwg_ptr_to_unsigned_char_array(ptr, size);
574
+ }
575
+ /**
576
+ * Converts one C++ signed char array to one JavaScript number array.
577
+ * @group Array Methods
578
+ * @param ptr Pointer to C++ signed char array.
579
+ * @param size The size of C++ signed char array.
580
+ * @returns Returns one JavaScript number array from the specified C++ signed char array.
581
+ */
582
+ dwg_ptr_to_signed_char_array(ptr, size) {
583
+ return this.wasmInstance.dwg_ptr_to_signed_char_array(ptr, size);
584
+ }
585
+ /**
586
+ * Converts one C++ unsigned int16 array to one JavaScript number array.
587
+ * @group Array Methods
588
+ * @param ptr Pointer to C++ unsigned int16 array.
589
+ * @param size The size of C++ unsigned int16 array.
590
+ * @returns Returns one JavaScript number array from the specified C++ unsigned int16 array.
591
+ */
592
+ dwg_ptr_to_uint16_t_array(ptr, size) {
593
+ return this.wasmInstance.dwg_ptr_to_uint16_t_array(ptr, size);
594
+ }
595
+ /**
596
+ * Converts one C++ int16 array to one JavaScript number array.
597
+ * @group Array Methods
598
+ * @param ptr Pointer to C++ int16 array.
599
+ * @param size The size of C++ int16 array.
600
+ * @returns Returns one JavaScript number array from the specified C++ int16 array.
601
+ */
602
+ dwg_ptr_to_int16_t_array(ptr, size) {
603
+ return this.wasmInstance.dwg_ptr_to_int16_t_array(ptr, size);
604
+ }
605
+ /**
606
+ * Converts one C++ unsigned int32 array to one JavaScript number array.
607
+ * @group Array Methods
608
+ * @param ptr Pointer to C++ unsigned int32 array.
609
+ * @param size The size of C++ unsigned int32 array.
610
+ * @returns Returns one JavaScript number array from the specified C++ unsigned int32 array.
611
+ */
612
+ dwg_ptr_to_uint32_t_array(ptr, size) {
613
+ return this.wasmInstance.dwg_ptr_to_uint32_t_array(ptr, size);
614
+ }
615
+ /**
616
+ * Converts one C++ int32 array to one JavaScript number array.
617
+ * @group Array Methods
618
+ * @param ptr Pointer to C++ int32 array.
619
+ * @param size The size of C++ int32 array.
620
+ * @returns Returns one JavaScript number array from the specified C++ int32 array.
621
+ */
622
+ dwg_ptr_to_int32_t_array(ptr, size) {
623
+ return this.wasmInstance.dwg_ptr_to_int32_t_array(ptr, size);
624
+ }
625
+ /**
626
+ * Converts one C++ unsigned int64 array to one JavaScript number array.
627
+ * @group Array Methods
628
+ * @param ptr Pointer to C++ unsigned int64 array.
629
+ * @param size The size of C++ unsigned int64 array.
630
+ * @returns Returns one JavaScript number array from the specified C++ unsigned int64 array.
631
+ */
632
+ dwg_ptr_to_uint64_t_array(ptr, size) {
633
+ return this.wasmInstance.dwg_ptr_to_uint64_t_array(ptr, size);
634
+ }
635
+ /**
636
+ * Converts one C++ int64 array to one JavaScript number array.
637
+ * @group Array Methods
638
+ * @param ptr Pointer to C++ int64 array.
639
+ * @param size The size of C++ int64 array.
640
+ * @returns Returns one JavaScript number array from the specified C++ int64 array.
641
+ */
642
+ dwg_ptr_to_int64_t_array(ptr, size) {
643
+ return this.wasmInstance.dwg_ptr_to_int64_t_array(ptr, size);
644
+ }
645
+ /**
646
+ * Converts one C++ double array to one JavaScript number array.
647
+ * @group Array Methods
648
+ * @param ptr Pointer to C++ double array.
649
+ * @param size The size of C++ double array.
650
+ * @returns Returns one JavaScript number array from the specified C++ double array.
651
+ */
652
+ dwg_ptr_to_double_array(ptr, size) {
653
+ return this.wasmInstance.dwg_ptr_to_double_array(ptr, size);
654
+ }
655
+ /**
656
+ * Converts one C++ 2d point array to one JavaScript 2d point array.
657
+ * @group Array Methods
658
+ * @param ptr Pointer to C++ 2d point array.
659
+ * @param size The size of C++ 2 point array.
660
+ * @returns Returns one JavaScript 2d point array from the specified C++ 2d point array.
661
+ */
662
+ dwg_ptr_to_point2d_array(ptr, size) {
663
+ return this.wasmInstance.dwg_ptr_to_point2d_array(ptr, size);
664
+ }
665
+ /**
666
+ * Converts one C++ 3d point array to one JavaScript 3d point array.
667
+ * @group Array Methods
668
+ * @param ptr Pointer to C++ 3d point array.
669
+ * @param size The size of C++ 3d point array.
670
+ * @returns Returns one JavaScript 3d point array from the specified C++ 3d point array.
671
+ */
672
+ dwg_ptr_to_point3d_array(ptr, size) {
673
+ return this.wasmInstance.dwg_ptr_to_point3d_array(ptr, size);
674
+ }
675
+ /**
676
+ * Converts one C++ 4d point array to one JavaScript 4d point array.
677
+ * @group Array Methods
678
+ * @param ptr Pointer to C++ 4d point array.
679
+ * @param size The size of C++ 4d point array.
680
+ * @returns Returns one JavaScript 4d point array from the specified C++ 4d point array.
681
+ */
682
+ dwg_ptr_to_point4d_array(ptr, size) {
683
+ return this.wasmInstance.dwg_ptr_to_point4d_array(ptr, size);
684
+ }
685
+ /**
686
+ * Converts one C++ line type array to one JavaScript line type array.
687
+ * @group Array Methods
688
+ * @param ptr Pointer to C++ line type array.
689
+ * @param size The size of C++ line type array.
690
+ * @returns Returns one JavaScript line type array from the specified C++ line type array.
691
+ */
692
+ dwg_ptr_to_ltype_dash_array(ptr, size) {
693
+ return this.wasmInstance.dwg_ptr_to_ltype_dash_array(ptr, size);
694
+ }
695
+ /**
696
+ * Converts one C++ table cell array to one JavaScript table cell array.
697
+ * @group Array Methods
698
+ * @group Dwg_Entity_TABLE Methods
699
+ * @param ptr Pointer to C++ table cell array.
700
+ * @param size The size of C++ table cell array.
701
+ * @returns Returns one JavaScript table cell array from the specified C++ table cell array.
702
+ */
703
+ dwg_ptr_to_table_cell_array(ptr, size) {
704
+ return this.wasmInstance.dwg_ptr_to_table_cell_array(ptr, size);
705
+ }
706
+ /**
707
+ * Converts one C++ hatch definition line array to one JavaScript hatch definition line array.
708
+ * @group Array Methods
709
+ * @group Dwg_Entity_HATCH Methods
710
+ * @param ptr Pointer to C++ hatch definition line array.
711
+ * @param size The size of C++ hatch definition line array.
712
+ * @returns Returns one JavaScript hatch definition line array from the specified C++ hatch definition line array.
713
+ */
714
+ dwg_ptr_to_hatch_defline_array(ptr, size) {
715
+ return this.wasmInstance.dwg_ptr_to_hatch_defline_array(ptr, size);
716
+ }
717
+ /**
718
+ * Converts one C++ hatch path array to one JavaScript hatch path array.
719
+ * @group Array Methods
720
+ * @group Dwg_Entity_HATCH Methods
721
+ * @param ptr Pointer to C++ hatch path array.
722
+ * @param size The size of C++ hatch path array.
723
+ * @returns Returns one JavaScript hatch path array from the specified C++ hatch path array.
724
+ */
725
+ dwg_ptr_to_hatch_path_array(ptr, size) {
726
+ return this.wasmInstance.dwg_ptr_to_hatch_path_array(ptr, size);
727
+ }
728
+ /**
729
+ * Converts one C++ hatch gradient color array to one JavaScript hatch gradient color array.
730
+ * @group Array Methods
731
+ * @group Dwg_Entity_HATCH Methods
732
+ * @param ptr Pointer to C++ hatch gradient color array.
733
+ * @param size The size of C++ hatch gradient color array.
734
+ * @returns Returns one JavaScript hatch gradient color array from the specified C++ hatch gradient color array.
735
+ */
736
+ dwg_ptr_to_hatch_gradient_color_array(ptr, size) {
737
+ return this.wasmInstance.dwg_ptr_to_hatch_gradient_color_array(ptr, size);
738
+ }
739
+ /**
740
+ * Converts one C++ mline vertex array to one JavaScript mline vertex array.
741
+ * @group Array Methods
742
+ * @group Dwg_Entity_MLINE Methods
743
+ * @param ptr Pointer to C++ mline vertex array.
744
+ * @param size The size of C++ mline vertex array.
745
+ * @returns Returns one JavaScript mline vertex array from the specified C++ mline vertex array.
746
+ */
747
+ dwg_ptr_to_mline_vertex_array(ptr, size) {
748
+ return this.wasmInstance.dwg_ptr_to_mline_vertex_array(ptr, size);
749
+ }
750
+ /**
751
+ * Generic field value getter. Used to get the field value of one object or entity.
752
+ * @group Dynamic API Methods
753
+ * @param obj Pointer to one object or entity
754
+ * @param field Field name of one object or entity
755
+ * @returns Returns the field value of one object or entity.
756
+ */
757
+ dwg_dynapi_entity_value(obj, field) {
758
+ const value = this.wasmInstance.dwg_dynapi_entity_value(obj, field);
759
+ if (value.bin && this.decoder) {
760
+ value.data = this.decoder.decode(value.bin);
761
+ }
762
+ return value;
763
+ }
764
+ /**
765
+ * Header field value getter. Used to get the field value of dwg/dxf header.
766
+ * @group Dynamic API Methods
767
+ * @param data Pointer to Dwg_Data instance.
768
+ * @param field Field name of header.
769
+ * @returns Returns the field value of dwg/dxf header.
770
+ */
771
+ dwg_dynapi_header_value(data, field) {
772
+ return this.wasmInstance.dwg_dynapi_header_value(data, field);
773
+ }
774
+ /**
775
+ * The common field value getter. Used to get the value of object or entity common fields.
776
+ * @group Dynamic API Methods
777
+ * @param obj Pointer to one object or entity
778
+ * @param field The name of object or entity common fields.
779
+ * @returns Returns the value of object or entity common fields.
780
+ */
781
+ dwg_dynapi_common_value(obj, field) {
782
+ return this.wasmInstance.dwg_dynapi_common_value(obj, field);
783
+ }
784
+ /**
785
+ * The field of one object or entity may not be primitive type. It means one field may consist of
786
+ * multiple sub-fields. This method is used to get the sub-field value of those complex field.
787
+ * @group Dynamic API Methods
788
+ * @param obj Pointer to one object or entity.
789
+ * @param subclass The class name of the field with complex type.
790
+ * @param field The field name of one object or entit.
791
+ * @returns Returns the sub-field value of one complex field.
792
+ */
793
+ dwg_dynapi_subclass_value(obj, subclass, field) {
794
+ return this.wasmInstance.dwg_dynapi_subclass_value(obj, subclass, field);
795
+ }
796
+ /**
797
+ * Returns the handle of one Dwg_Object instance.
798
+ * @group Dwg_Object Methods
799
+ * @param ptr Pointer to one Dwg_Object instance.
800
+ * @returns Returns the handle of one Dwg_Object instance.
801
+ */
802
+ dwg_object_get_handle_object(ptr) {
803
+ return this.wasmInstance.dwg_object_get_handle_object(ptr);
804
+ }
805
+ /**
806
+ * Returns the handle of one Dwg_Object_Object instance.
807
+ * @group Dwg_Object_Object Methods
808
+ * @param ptr Pointer to one Dwg_Object_Object instance.
809
+ * @returns Returns the handle of one Dwg_Object_Object instance.
810
+ */
811
+ dwg_object_object_get_handle_object(ptr) {
812
+ return this.wasmInstance.dwg_object_object_get_handle_object(ptr);
813
+ }
814
+ /**
815
+ * Returns the owner handle of one Dwg_Object_Object instance.
816
+ * @group Dwg_Object_Object Methods
817
+ * @param ptr Pointer to one Dwg_Object_Object instance.
818
+ * @returns Returns the owner handle of one Dwg_Object_Object instance.
819
+ */
820
+ dwg_object_object_get_ownerhandle_object(ptr) {
821
+ return this.wasmInstance.dwg_object_object_get_ownerhandle_object(ptr);
822
+ }
823
+ /**
824
+ * Returns the handle of one Dwg_Object_Entity instance.
825
+ * @group Dwg_Object_Entity Methods
826
+ * @param ptr Pointer to one Dwg_Object_Entity instance.
827
+ * @returns Returns the handle of one Dwg_Object_Entity instance.
828
+ */
829
+ dwg_object_entity_get_handle_object(ptr) {
830
+ return this.wasmInstance.dwg_object_entity_get_handle_object(ptr);
831
+ }
832
+ /**
833
+ * Returns the owner handle of one Dwg_Object_Entity instance.
834
+ * @group Dwg_Object_Entity Methods
835
+ * @param ptr Pointer to one Dwg_Object_Entity instance.
836
+ * @returns Returns the owner handle of one Dwg_Object_Entity instance.
837
+ */
838
+ dwg_object_entity_get_ownerhandle_object(ptr) {
839
+ return this.wasmInstance.dwg_object_entity_get_ownerhandle_object(ptr);
840
+ }
841
+ /**
842
+ * Returns hard-owner ID/handle to owner dictionary of one Dwg_Object_Entity instance.
843
+ * @group Dwg_Object_Entity Methods
844
+ * @param ptr Pointer to one Dwg_Object_Entity instance.
845
+ * @returns Returns hard-owner ID/handle to owner dictionary of one Dwg_Object_Entity instance.
846
+ */
847
+ dwg_object_entity_get_xdicobjhandle_object(ptr) {
848
+ return this.wasmInstance.dwg_object_entity_get_xdicobjhandle_object(ptr);
849
+ }
850
+ /**
851
+ * Returns the layer handle of one Dwg_Object_Entity instance.
852
+ * @group Dwg_Object_Entity Methods
853
+ * @param ptr Pointer to one Dwg_Object_Entity instance.
854
+ * @returns Returns the layer handle of one Dwg_Object_Entity instance.
855
+ */
856
+ dwg_object_entity_get_layer_object_ref(ptr) {
857
+ return this.wasmInstance.dwg_object_entity_get_layer_object_ref(ptr);
858
+ }
859
+ /**
860
+ * Returns the line type handle of one Dwg_Object_Entity instance.
861
+ * @group Dwg_Object_Entity Methods
862
+ * @param ptr Pointer to one Dwg_Object_Entity instance.
863
+ * @returns Returns the line type handle of one Dwg_Object_Entity instance.
864
+ */
865
+ dwg_object_entity_get_ltype_object_ref(ptr) {
866
+ return this.wasmInstance.dwg_object_entity_get_ltype_object_ref(ptr);
867
+ }
868
+ /**
869
+ * Returns color value of one Dwg_Object_Entity instance.
870
+ * @group Dwg_Object_Entity Methods
871
+ * @param ptr Pointer to one Dwg_Object_Entity instance.
872
+ * @returns Returns color value of one Dwg_Object_Entity instance.
873
+ */
874
+ dwg_object_entity_get_color_object(ptr) {
875
+ return this.wasmInstance.dwg_object_entity_get_color_object(ptr);
876
+ }
877
+ /**
878
+ * Returns xdata of one Dwg_Object_Entity instance.
879
+ * @group Dwg_Object_Entity Methods
880
+ * @param ptr Pointer to one Dwg_Object_Entity instance.
881
+ * @returns Returns xdata of one Dwg_Object_Entity instance.
882
+ */
883
+ dwg_object_entity_get_xdata(ptr) {
884
+ return this.wasmInstance.dwg_object_entity_get_xdata(ptr);
885
+ }
886
+ /**
887
+ * Returns pointer to BLOCK_HEADER owner for generic entity from ent->ownerhandle.
888
+ * @group Dwg_Object_Entity Methods
889
+ * @param ptr Pointer to one Dwg_Object_Entity instance.
890
+ * @returns Returns pointer to BLOCK_HEADER owner.
891
+ */
892
+ dwg_entity_owner(ptr) {
893
+ const wasmInstance = this.wasmInstance;
894
+ return wasmInstance.dwg_entity_owner(ptr);
895
+ }
896
+ /**
897
+ * Returns block name of one Dwg_Entity_* instance with one block field. For example,
898
+ * dimension entities have one 'block' field which represents the block that contains
899
+ * the entities that make up the dimension picture.
900
+ * @group Dwg_Entity_* Methods
901
+ * @param ptr Pointer to one Dwg_Entity_* instance with one block field.
902
+ * @param field Field name of the block.
903
+ * @returns Returns block name of one Dwg_Entity_* instance.
904
+ */
905
+ dwg_entity_get_block_name(ptr, field) {
906
+ const wasmInstance = this.wasmInstance;
907
+ const block_header_ref = wasmInstance.dwg_dynapi_entity_value(ptr, field)
908
+ .data;
909
+ const block_header_obj = wasmInstance.dwg_ref_get_object(block_header_ref);
910
+ const block_header_tio = wasmInstance.dwg_object_to_object_tio(block_header_obj);
911
+ const block = this.dwg_entity_block_header_get_block(block_header_tio);
912
+ return block.name;
913
+ }
914
+ /**
915
+ * Returns dimension style name of one Dwg_Entity_* instance with one dimension style
916
+ * field.
917
+ * @group Dwg_Entity_* Methods
918
+ * @param ptr Pointer to one Dwg_Entity_* instance.
919
+ * @param field Field name of the dimension style.
920
+ * @returns Returns dimension style name of one Dwg_Entity_* instance.
921
+ */
922
+ dwg_entity_get_dimstyle_name(ptr, field = 'dimstyle') {
923
+ const wasmInstance = this.wasmInstance;
924
+ const dimstyle_ref = wasmInstance.dwg_dynapi_entity_value(ptr, field)
925
+ .data;
926
+ const dimstyle_obj = wasmInstance.dwg_ref_get_object(dimstyle_ref);
927
+ const dimstyle_tio = wasmInstance.dwg_object_to_object_tio(dimstyle_obj);
928
+ const dimstyle_name = this.dwg_dynapi_entity_value(dimstyle_tio, 'name')
929
+ .data;
930
+ return dimstyle_name;
931
+ }
932
+ /**
933
+ * Returns block entity pointed by the specified block header.
934
+ * @group Dwg_Entity_BLOCK_HEADER Methods
935
+ * @param ptr Pointer to one Dwg_Entity_BLOCK_HEADER instance.
936
+ * @returns Returns block entity pointed by the specified block header.
937
+ */
938
+ dwg_entity_block_header_get_block(ptr) {
939
+ const wasmInstance = this.wasmInstance;
940
+ const block_ref = wasmInstance.dwg_dynapi_entity_value(ptr, 'block_entity')
941
+ .data;
942
+ const block_obj = wasmInstance.dwg_ref_get_object(block_ref);
943
+ const block_tio = wasmInstance.dwg_object_to_entity_tio(block_obj);
944
+ const name = wasmInstance.dwg_dynapi_entity_value(block_tio, 'name')
945
+ .data;
946
+ const base_pt = wasmInstance.dwg_dynapi_entity_value(block_tio, 'base_pt')
947
+ .data;
948
+ return {
949
+ name,
950
+ base_pt // preR13 only
951
+ };
952
+ }
953
+ /**
954
+ * Returns preview image of the block pointed by the specified block header.
955
+ * @group Dwg_Entity_BLOCK_HEADER Methods
956
+ * @param ptr Pointer to one Dwg_Entity_BLOCK_HEADER instance.
957
+ * @returns Returns preview image of the block pointed by the specified block header.
958
+ */
959
+ dwg_entity_block_header_get_preview(ptr) {
960
+ const wasmInstance = this.wasmInstance;
961
+ return wasmInstance.dwg_entity_block_header_get_preview(ptr)
962
+ .data;
963
+ }
964
+ /**
965
+ * Returns preview binary data of one entity (common entity preview field).
966
+ * For PROXY_ENTITY this contains the proxy graphics data.
967
+ */
968
+ dwg_entity_get_preview(ptr) {
969
+ const wasm = this.wasmInstance;
970
+ if (typeof wasm.dwg_entity_get_preview !== 'function') {
971
+ return null;
972
+ }
973
+ const result = wasm.dwg_entity_get_preview(ptr);
974
+ return result?.data ?? null;
975
+ }
976
+ /**
977
+ * Returns entity binary data of one Dwg_Entity_PROXY_ENTITY instance.
978
+ * @group Dwg_Entity_PROXY_ENTITY Methods
979
+ * @param ptr Pointer to one Dwg_Entity_PROXY_ENTITY instance.
980
+ * @returns Entity data bytes, or null when absent.
981
+ */
982
+ dwg_entity_proxy_entity_get_entity_data(ptr) {
983
+ const wasm = this.wasmInstance;
984
+ if (typeof wasm.dwg_entity_proxy_entity_get_entity_data !== 'function') {
985
+ return null;
986
+ }
987
+ const result = wasm.dwg_entity_proxy_entity_get_entity_data(ptr);
988
+ return result?.data ?? null;
989
+ }
990
+ /**
991
+ * Returns the first entity owned by the block header or null
992
+ * @group Dwg_Entity_BLOCK_HEADER Methods
993
+ * @param ptr Pointer to the block header.
994
+ * @returns Returns the first entity owned by the block header or null
995
+ */
996
+ get_first_owned_entity(ptr) {
997
+ return this.wasmInstance.get_first_owned_entity(ptr);
998
+ }
999
+ /**
1000
+ * Returns the next entity owned by the block header or null.
1001
+ * @group Dwg_Entity_BLOCK_HEADER Methods
1002
+ * @param ptr Pointer to the block header.
1003
+ * @param current Pointer to the current entity in the block header.
1004
+ * @returns Returns the next entity owned by the block header or null.
1005
+ */
1006
+ get_next_owned_entity(ptr, current) {
1007
+ return this.wasmInstance.get_next_owned_entity(ptr, current);
1008
+ }
1009
+ /**
1010
+ * Returns text style name of one Dwg_Entity_MTEXT instance.
1011
+ * @group Dwg_Entity_MTEXT Methods
1012
+ * @param ptr Pointer to one Dwg_Entity_MTEXT instance.
1013
+ * @returns Returns text style name of one Dwg_Entity_MTEXT instance.
1014
+ */
1015
+ dwg_entity_mtext_get_style_name(ptr) {
1016
+ const wasmInstance = this.wasmInstance;
1017
+ const style_ref = wasmInstance.dwg_dynapi_entity_value(ptr, 'style')
1018
+ .data;
1019
+ const style_obj = wasmInstance.dwg_ref_get_object(style_ref);
1020
+ const style_tio = wasmInstance.dwg_object_to_object_tio(style_obj);
1021
+ const name = wasmInstance.dwg_dynapi_entity_value(style_tio, 'name')
1022
+ .data;
1023
+ return name;
1024
+ }
1025
+ /**
1026
+ * Returns text style name of one Dwg_Entity_TEXT instance.
1027
+ * @group Dwg_Entity_TEXT Methods
1028
+ * @param ptr Pointer to one Dwg_Entity_TEXT instance.
1029
+ * @returns Returns text style name of one Dwg_Entity_TEXT instance.
1030
+ */
1031
+ dwg_entity_text_get_style_name(ptr) {
1032
+ return this.dwg_entity_mtext_get_style_name(ptr);
1033
+ }
1034
+ /**
1035
+ * Returns the number of points in Dwg_Entity_POLYLINE_2D.
1036
+ * @group Dwg_Entity_POLYLINE_2D Methods
1037
+ * @param ptr Pointer to one Dwg_Object (not Dwg_Entity_POLYLINE_2D) instance.
1038
+ * @returns Returns the number of points in one Dwg_Entity_POLYLINE_2D.
1039
+ */
1040
+ dwg_entity_polyline_2d_get_numpoints(ptr) {
1041
+ const wasmInstance = this.wasmInstance;
1042
+ return wasmInstance.dwg_entity_polyline_2d_get_numpoints(ptr).data;
1043
+ }
1044
+ /**
1045
+ * Returns points in Dwg_Entity_POLYLINE_2D.
1046
+ * @group Dwg_Entity_POLYLINE_2D Methods
1047
+ * @param ptr Pointer to one Dwg_Object (not Dwg_Entity_POLYLINE_2D) instance.
1048
+ * @returns Returns points in one Dwg_Entity_POLYLINE_2D.
1049
+ */
1050
+ dwg_entity_polyline_2d_get_points(ptr) {
1051
+ const wasmInstance = this.wasmInstance;
1052
+ return wasmInstance.dwg_entity_polyline_2d_get_points(ptr)
1053
+ .data;
1054
+ }
1055
+ /**
1056
+ * Returns vertices in Dwg_Entity_POLYLINE_2D.
1057
+ * @group Dwg_Entity_POLYLINE_2D Methods
1058
+ * @param ptr Pointer to one Dwg_Object (not Dwg_Entity_POLYLINE_2D) instance.
1059
+ * @returns Returns vertices in one Dwg_Entity_POLYLINE_2D.
1060
+ */
1061
+ dwg_entity_polyline_2d_get_vertices(ptr) {
1062
+ const wasmInstance = this.wasmInstance;
1063
+ return wasmInstance.dwg_entity_polyline_2d_get_vertices(ptr)
1064
+ .data;
1065
+ }
1066
+ /**
1067
+ * Returns the number of points in Dwg_Entity_POLYLINE_3D.
1068
+ * @group Dwg_Entity_POLYLINE_3D Methods
1069
+ * @param ptr Pointer to one Dwg_Object (not Dwg_Entity_POLYLINE_3D) instance.
1070
+ * @returns Returns the number of points in one Dwg_Entity_POLYLINE_3D.
1071
+ */
1072
+ dwg_entity_polyline_3d_get_numpoints(ptr) {
1073
+ const wasmInstance = this.wasmInstance;
1074
+ return wasmInstance.dwg_entity_polyline_3d_get_numpoints(ptr).data;
1075
+ }
1076
+ /**
1077
+ * Returns points in Dwg_Entity_POLYLINE_3D.
1078
+ * @group Dwg_Entity_POLYLINE_3D Methods
1079
+ * @param ptr Pointer to one Dwg_Object (not Dwg_Entity_POLYLINE_3D) instance.
1080
+ * @returns Returns points in one Dwg_Entity_POLYLINE_3D.
1081
+ */
1082
+ dwg_entity_polyline_3d_get_points(ptr) {
1083
+ const wasmInstance = this.wasmInstance;
1084
+ return wasmInstance.dwg_entity_polyline_3d_get_points(ptr)
1085
+ .data;
1086
+ }
1087
+ /**
1088
+ * Returns vertices in Dwg_Entity_POLYLINE_3D.
1089
+ * @group Dwg_Entity_POLYLINE_3D Methods
1090
+ * @param ptr Pointer to one Dwg_Object (not Dwg_Entity_POLYLINE_3D) instance.
1091
+ * @returns Returns vertices in one Dwg_Entity_POLYLINE_3D.
1092
+ */
1093
+ dwg_entity_polyline_3d_get_vertices(ptr) {
1094
+ const wasmInstance = this.wasmInstance;
1095
+ return wasmInstance.dwg_entity_polyline_3d_get_vertices(ptr)
1096
+ .data;
1097
+ }
1098
+ /**
1099
+ * Returns attributes associated with INSERT entity.
1100
+ * @group Dwg_Entity_INSERT Methods
1101
+ * @param ptr Pointer to one Dwg_Object (not Dwg_Entity_INSERT) instance.
1102
+ * @returns Returns attributes associated with INSERT entity.
1103
+ */
1104
+ dwg_entity_insert_get_attribs(ptr) {
1105
+ const wasmInstance = this.wasmInstance;
1106
+ return wasmInstance.dwg_entity_insert_get_attribs(ptr)
1107
+ .data;
1108
+ }
1109
+ /**
1110
+ * Returns texts in Dwg_Object_DICTIONARY.
1111
+ * @group Dwg_Object_DICTIONARY Methods
1112
+ * @param ptr Pointer to one Dwg_Object (not Dwg_Object_DICTIONARY) instance.
1113
+ * @returns Returns texts in one Dwg_Object_DICTIONARY.
1114
+ */
1115
+ dwg_object_dictionary_get_texts(ptr) {
1116
+ const wasmInstance = this.wasmInstance;
1117
+ return wasmInstance.dwg_object_dictionary_get_texts(ptr)
1118
+ .data;
1119
+ }
1120
+ }
1121
+ //# sourceMappingURL=libredwg-core.js.map