@mlightcad/libredwg-converter 3.15.14 → 3.15.16

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.
@@ -60,7 +60,23 @@ var __values = (this && this.__values) || function(o) {
60
60
  };
61
61
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
62
62
  };
63
- import { AcCmColor, AcDbBatchProcessing, AcDbBlockTableRecord, acdbCreateWorkerApi, AcDbDatabaseConverter, AcDbDictionary, AcDbDictionaryVar, AcDbDimStyleTableRecord, acdbHexStringsToBytes, acdbImportDynBlockMetadata, AcDbLayerTableRecord, AcDbLayout, AcDbLinetypeTableRecord, acdbNormalizeExtensionDictionaryId, AcDbOpenDatabaseError, AcDbRasterImageDef, acdbReadLayerFilterTree, AcDbTextStyleTableRecord, AcDbViewportTableRecord, ByLayer, DEFAULT_MLEADER_STYLE, DEFAULT_TEXT_STYLE, VPORT_FALLBACK_CENTER_2D, VPORT_FALLBACK_LLC, VPORT_FALLBACK_URC, VPORT_FALLBACK_VIEW_DIR, VPORT_FALLBACK_VIEW_TARGET } from '@mlightcad/data-model';
63
+ var __read = (this && this.__read) || function (o, n) {
64
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
65
+ if (!m) return o;
66
+ var i = m.call(o), r, ar = [], e;
67
+ try {
68
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
69
+ }
70
+ catch (error) { e = { error: error }; }
71
+ finally {
72
+ try {
73
+ if (r && !r.done && (m = i["return"])) m.call(i);
74
+ }
75
+ finally { if (e) throw e.error; }
76
+ }
77
+ return ar;
78
+ };
79
+ import { AcCmColor, AcDbBatchProcessing, AcDbBlockTableRecord, acdbCreateWorkerApi, AcDbDatabaseConverter, AcDbDictionary, AcDbDictionaryVar, AcDbDimStyleTableRecord, acdbHexStringsToBytes, acdbImportDynBlockMetadata, AcDbLayerTableRecord, AcDbLayout, AcDbLinetypeTableRecord, acdbNormalizeDimStyleColorNumber, acdbNormalizeExtensionDictionaryId, AcDbOpenDatabaseError, AcDbRasterImageDef, acdbReadLayerFilterTree, AcDbTextStyleTableRecord, AcDbViewportTableRecord, ByLayer, DEFAULT_MLEADER_STYLE, DEFAULT_TEXT_STYLE, VPORT_FALLBACK_CENTER_2D, VPORT_FALLBACK_LLC, VPORT_FALLBACK_URC, VPORT_FALLBACK_VIEW_DIR, VPORT_FALLBACK_VIEW_TARGET } from '@mlightcad/data-model';
64
80
  import { AcDbEntityConverter } from './AcDbEntitiyConverter.js';
65
81
  import { AcDbObjectConverter } from './AcDbObjectConverter.js';
66
82
  var MODEL_SPACE = '*MODEL_SPACE';
@@ -146,6 +162,7 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
146
162
  db.ensureTextStyleDefaults();
147
163
  };
148
164
  AcDbLibreDwgConverter.prototype.processDimStyles = function (model, db) {
165
+ var e_1, _a;
149
166
  var _this = this;
150
167
  var dimStyles = model.tables.DIMSTYLE.entries;
151
168
  dimStyles.forEach(function (item) {
@@ -171,6 +188,9 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
171
188
  dimtvp: item.DIMTVP,
172
189
  dimtfac: item.DIMTFAC,
173
190
  dimgap: item.DIMGAP,
191
+ dimtfill: item.DIMTFILL === 1 || item.DIMTFILL === 2 ? item.DIMTFILL : 0,
192
+ dimtfillclr: acdbNormalizeDimStyleColorNumber(item.DIMTFILLCLR),
193
+ dimtxtdirection: item.DIMTXTDIRECTION === 1 ? 1 : 0,
174
194
  dimaltrnd: item.DIMALTRND,
175
195
  dimtol: item.DIMTOL == null || item.DIMTOL == 0 ? 0 : 1,
176
196
  dimlim: item.DIMLIM == null || item.DIMLIM == 0 ? 0 : 1,
@@ -187,9 +207,12 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
187
207
  dimsah: item.DIMSAH,
188
208
  dimtix: item.DIMTIX,
189
209
  dimsoxd: item.DIMSOXD,
190
- dimclrd: item.DIMCLRD,
191
- dimclre: item.DIMCLRE,
192
- dimclrt: item.DIMCLRT,
210
+ // LibreDWG returns CMC objects / packed ints for these — normalize to
211
+ // plain ACI (0/1..255/256) or packed RGB so dim block builders never
212
+ // see NaN colorIndex when constructing MTEXT.
213
+ dimclrd: acdbNormalizeDimStyleColorNumber(item.DIMCLRD),
214
+ dimclre: acdbNormalizeDimStyleColorNumber(item.DIMCLRE),
215
+ dimclrt: acdbNormalizeDimStyleColorNumber(item.DIMCLRT),
193
216
  dimadec: item.DIMADEC || 0,
194
217
  dimunit: item.DIMUNIT || 2,
195
218
  dimdec: item.DIMDEC,
@@ -211,7 +234,7 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
211
234
  dimfit: item.DIMFIT || 0,
212
235
  dimupt: item.DIMUPT,
213
236
  dimatfit: item.DIMATFIT,
214
- dimtxsty: DEFAULT_TEXT_STYLE, // TODO: Set correct value
237
+ dimtxsty: _this.resolveDimTextStyleName(model, item.DIMTXSTY),
215
238
  dimldrblk: '', // TODO: Set correct value
216
239
  dimblk: item.DIMBLK || '', // TODO: Set correct value
217
240
  dimblk1: item.DIMBLK1 || '', // TODO: Set correct value
@@ -223,6 +246,47 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
223
246
  _this.processCommonTableEntryAttrs(item, record);
224
247
  db.tables.dimStyleTable.add(record);
225
248
  });
249
+ var scales = model.dimStyleAnnotationScales;
250
+ if (scales) {
251
+ try {
252
+ for (var _b = __values(Object.entries(scales)), _c = _b.next(); !_c.done; _c = _b.next()) {
253
+ var _d = __read(_c.value, 2), name_1 = _d[0], factor = _d[1];
254
+ db.setDimStyleAnnotationScale(name_1, factor);
255
+ }
256
+ }
257
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
258
+ finally {
259
+ try {
260
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
261
+ }
262
+ finally { if (e_1) throw e_1.error; }
263
+ }
264
+ }
265
+ };
266
+ /**
267
+ * DIMTXSTY is a hard pointer. LibreDWG exposes it as a numeric handle
268
+ * (for example 0x28D → 653) rather than the text style name.
269
+ */
270
+ AcDbLibreDwgConverter.prototype.resolveDimTextStyleName = function (model, dimTxsty) {
271
+ if (typeof dimTxsty === 'string') {
272
+ var text_1 = dimTxsty.trim();
273
+ if (text_1 && !/^[0-9]+$/.test(text_1) && !/^[0-9A-F]+$/i.test(text_1)) {
274
+ return text_1;
275
+ }
276
+ if (text_1 && /[A-Z]/i.test(text_1)) {
277
+ var byHex = model.tables.STYLE.entries.find(function (entry) { return String(entry.handle).toUpperCase() === text_1.toUpperCase(); });
278
+ if (byHex === null || byHex === void 0 ? void 0 : byHex.name)
279
+ return byHex.name;
280
+ }
281
+ }
282
+ var numeric = typeof dimTxsty === 'number' ? dimTxsty : Number(dimTxsty);
283
+ if (Number.isFinite(numeric) && numeric > 0) {
284
+ var hex_1 = Math.trunc(numeric).toString(16).toUpperCase();
285
+ var match = model.tables.STYLE.entries.find(function (entry) { return String(entry.handle).toUpperCase() === hex_1; });
286
+ if (match === null || match === void 0 ? void 0 : match.name)
287
+ return match.name;
288
+ }
289
+ return DEFAULT_TEXT_STYLE;
226
290
  };
227
291
  AcDbLibreDwgConverter.prototype.processLayers = function (model, db) {
228
292
  var _this = this;
@@ -522,7 +586,7 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
522
586
  }); });
523
587
  };
524
588
  AcDbLibreDwgConverter.prototype.processHeader = function (model, db) {
525
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
589
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
526
590
  var thumbnail = model.thumbnailImage;
527
591
  if (thumbnail === null || thumbnail === void 0 ? void 0 : thumbnail.length) {
528
592
  db.thumbnailImage = thumbnail;
@@ -564,7 +628,13 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
564
628
  db.pdmode = (_j = header.PDMODE) !== null && _j !== void 0 ? _j : 0;
565
629
  db.pdsize = (_k = header.PDSIZE) !== null && _k !== void 0 ? _k : 0.0;
566
630
  db.textstyle = (_l = header.TEXTSTYLE) !== null && _l !== void 0 ? _l : DEFAULT_TEXT_STYLE;
567
- var cmleaderStyle = (_m = this.normalizeHeaderStringValue(header.CMLEADERSTYLE)) !== null && _m !== void 0 ? _m : DEFAULT_MLEADER_STYLE;
631
+ // Match DXF header reader: new dimensions must inherit $DIMSTYLE.
632
+ // Without this, DWG loads leave db.dimstyle as the constructor default
633
+ // ("Standard"), so dims pick imperial 0.18 text/arrow while the drawing's
634
+ // active style (e.g. metric "2-1" with dimtxt/dimasz=3) is ignored.
635
+ db.dimstyle =
636
+ (_m = this.normalizeHeaderStringValue(header.DIMSTYLE)) !== null && _m !== void 0 ? _m : DEFAULT_TEXT_STYLE;
637
+ var cmleaderStyle = (_o = this.normalizeHeaderStringValue(header.CMLEADERSTYLE)) !== null && _o !== void 0 ? _o : DEFAULT_MLEADER_STYLE;
568
638
  db.cmleaderstyle = cmleaderStyle;
569
639
  };
570
640
  AcDbLibreDwgConverter.prototype.processCommonTableEntryAttrs = function (entry, dbEntry) {
@@ -580,6 +650,13 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
580
650
  this.processScales(model, db);
581
651
  this.processDictionaryVars(model, db);
582
652
  this.processMTextObjectContextData(model, db);
653
+ this.processTextObjectContextData(model, db);
654
+ this.processDimensionObjectContextData(model, db);
655
+ this.processHatchScaleContextData(model, db);
656
+ this.processBlkRefObjectContextData(model, db);
657
+ this.processLeaderObjectContextData(model, db);
658
+ this.processMLeaderObjectContextData(model, db);
659
+ this.processMTextAttributeObjectContextData(model, db);
583
660
  this.processXRecords(model, db);
584
661
  this.processLayouts(model, db);
585
662
  this.processImageDefs(model, db);
@@ -589,6 +666,7 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
589
666
  this.processMLeaderStyles(model, db);
590
667
  this.processDynBlockMetadata(model, db);
591
668
  this.finishCannoscale(model, db);
669
+ this.finishAnnoallvisible(model, db);
592
670
  };
593
671
  /**
594
672
  * Imports extension dictionaries and (when present) representation pointers
@@ -601,7 +679,7 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
601
679
  * placeholder is created by {@link acdbImportDynBlockMetadata}.
602
680
  */
603
681
  AcDbLibreDwgConverter.prototype.processDynBlockMetadata = function (model, db) {
604
- var e_1, _a;
682
+ var e_2, _a;
605
683
  var _b, _c;
606
684
  var normalize = function (handle) {
607
685
  return handle == null || handle === '' || handle === 0
@@ -622,12 +700,12 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
622
700
  }
623
701
  }
624
702
  }
625
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
703
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
626
704
  finally {
627
705
  try {
628
706
  if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
629
707
  }
630
- finally { if (e_1) throw e_1.error; }
708
+ finally { if (e_2) throw e_2.error; }
631
709
  }
632
710
  var dictObjects = model.objects.DICTIONARY;
633
711
  if (!(dictObjects === null || dictObjects === void 0 ? void 0 : dictObjects.length))
@@ -636,10 +714,10 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
636
714
  var _a;
637
715
  var entries = [];
638
716
  var src = (_a = dict.entries) !== null && _a !== void 0 ? _a : {};
639
- for (var name_1 in src) {
640
- var target = src[name_1];
641
- if (name_1 && target) {
642
- entries.push({ name: name_1, handle: normalize(String(target)) });
717
+ for (var name_2 in src) {
718
+ var target = src[name_2];
719
+ if (name_2 && target) {
720
+ entries.push({ name: name_2, handle: normalize(String(target)) });
643
721
  }
644
722
  }
645
723
  return {
@@ -679,10 +757,10 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
679
757
  var _a;
680
758
  var entries = {};
681
759
  var src = (_a = dict.entries) !== null && _a !== void 0 ? _a : {};
682
- for (var name_2 in src) {
683
- var target = src[name_2];
684
- if (name_2 && target) {
685
- entries[name_2] = normalize(String(target));
760
+ for (var name_3 in src) {
761
+ var target = src[name_3];
762
+ if (name_3 && target) {
763
+ entries[name_3] = normalize(String(target));
686
764
  }
687
765
  }
688
766
  dictionaries.set(normalize(dict.handle), {
@@ -714,7 +792,7 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
714
792
  var layoutDict = db.objects.layout;
715
793
  var layouts = model.objects.LAYOUT;
716
794
  layouts.forEach(function (layout) {
717
- var e_2, _a;
795
+ var e_3, _a;
718
796
  var dbLayout = new AcDbLayout();
719
797
  dbLayout.layoutName = layout.layoutName;
720
798
  dbLayout.tabOrder = layout.tabOrder;
@@ -734,12 +812,12 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
734
812
  }
735
813
  }
736
814
  }
737
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
815
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
738
816
  finally {
739
817
  try {
740
818
  if (btrs_1_1 && !btrs_1_1.done && (_a = btrs_1.return)) _a.call(btrs_1);
741
819
  }
742
- finally { if (e_2) throw e_2.error; }
820
+ finally { if (e_3) throw e_3.error; }
743
821
  }
744
822
  // If the layout is not found in the block table due to some unknow reason,
745
823
  // let's set the model space block table record id.
@@ -804,7 +882,7 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
804
882
  });
805
883
  };
806
884
  AcDbLibreDwgConverter.prototype.processScales = function (model, db) {
807
- var e_3, _a;
885
+ var e_4, _a;
808
886
  var scales = this.optionalObjectArray(model, 'SCALE');
809
887
  if (!(scales === null || scales === void 0 ? void 0 : scales.length))
810
888
  return;
@@ -819,16 +897,16 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
819
897
  scaleDict.setAt(key, dbScale);
820
898
  }
821
899
  }
822
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
900
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
823
901
  finally {
824
902
  try {
825
903
  if (scales_1_1 && !scales_1_1.done && (_a = scales_1.return)) _a.call(scales_1);
826
904
  }
827
- finally { if (e_3) throw e_3.error; }
905
+ finally { if (e_4) throw e_4.error; }
828
906
  }
829
907
  };
830
908
  AcDbLibreDwgConverter.prototype.processDictionaryVars = function (model, db) {
831
- var e_4, _a;
909
+ var e_5, _a;
832
910
  var dictVars = this.optionalObjectArray(model, 'DICTIONARYVAR');
833
911
  if (!(dictVars === null || dictVars === void 0 ? void 0 : dictVars.length))
834
912
  return;
@@ -842,16 +920,16 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
842
920
  dictVarDict.setAt(dbVar.objectId, dbVar);
843
921
  }
844
922
  }
845
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
923
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
846
924
  finally {
847
925
  try {
848
926
  if (dictVars_1_1 && !dictVars_1_1.done && (_a = dictVars_1.return)) _a.call(dictVars_1);
849
927
  }
850
- finally { if (e_4) throw e_4.error; }
928
+ finally { if (e_5) throw e_5.error; }
851
929
  }
852
930
  };
853
931
  AcDbLibreDwgConverter.prototype.processMTextObjectContextData = function (model, db) {
854
- var e_5, _a;
932
+ var e_6, _a;
855
933
  var _b;
856
934
  var contexts = (_b = this.optionalObjectArray(model, 'MTEXTOBJECTCONTEXTDATA')) !== null && _b !== void 0 ? _b : this.optionalObjectArray(model, 'ACDB_MTEXTOBJECTCONTEXTDATA_CLASS');
857
935
  if (!(contexts === null || contexts === void 0 ? void 0 : contexts.length))
@@ -866,16 +944,214 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
866
944
  contextDict.setAt(dbContext.objectId, dbContext);
867
945
  }
868
946
  }
869
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
947
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
870
948
  finally {
871
949
  try {
872
950
  if (contexts_1_1 && !contexts_1_1.done && (_a = contexts_1.return)) _a.call(contexts_1);
873
951
  }
874
- finally { if (e_5) throw e_5.error; }
952
+ finally { if (e_6) throw e_6.error; }
953
+ }
954
+ };
955
+ AcDbLibreDwgConverter.prototype.processDimensionObjectContextData = function (model, db) {
956
+ var e_7, _a, e_8, _b;
957
+ var keys = [
958
+ 'ALDIMOBJECTCONTEXTDATA',
959
+ 'ACDB_ALDIMOBJECTCONTEXTDATA_CLASS',
960
+ 'ANGDIMOBJECTCONTEXTDATA',
961
+ 'ACDB_ANGDIMOBJECTCONTEXTDATA_CLASS',
962
+ 'ARCDIMOBJECTCONTEXTDATA',
963
+ 'ACDB_ARCDIMOBJECTCONTEXTDATA_CLASS',
964
+ 'DMDIMOBJECTCONTEXTDATA',
965
+ 'ACDB_DMDIMOBJECTCONTEXTDATA_CLASS',
966
+ 'ORDDIMOBJECTCONTEXTDATA',
967
+ 'ACDB_ORDDIMOBJECTCONTEXTDATA_CLASS',
968
+ 'RADDIMOBJECTCONTEXTDATA',
969
+ 'ACDB_RADDIMOBJECTCONTEXTDATA_CLASS',
970
+ 'RADIMOBJECTCONTEXTDATA',
971
+ 'ACDB_RADIMOBJECTCONTEXTDATA_CLASS',
972
+ 'RADDIMLGCOBJECTCONTEXTDATA',
973
+ 'ACDB_RADDIMLGCOBJECTCONTEXTDATA_CLASS'
974
+ ];
975
+ var objectConverter = new AcDbObjectConverter();
976
+ var contextDict = db.objects.objectContextData;
977
+ try {
978
+ for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
979
+ var key = keys_1_1.value;
980
+ var contexts = this.optionalObjectArray(model, key);
981
+ if (!(contexts === null || contexts === void 0 ? void 0 : contexts.length))
982
+ continue;
983
+ try {
984
+ for (var contexts_2 = (e_8 = void 0, __values(contexts)), contexts_2_1 = contexts_2.next(); !contexts_2_1.done; contexts_2_1 = contexts_2.next()) {
985
+ var context = contexts_2_1.value;
986
+ var dbContext = objectConverter.convertDimensionObjectContextData(context);
987
+ if (dbContext.objectId) {
988
+ contextDict.setAt(dbContext.objectId, dbContext);
989
+ }
990
+ }
991
+ }
992
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
993
+ finally {
994
+ try {
995
+ if (contexts_2_1 && !contexts_2_1.done && (_b = contexts_2.return)) _b.call(contexts_2);
996
+ }
997
+ finally { if (e_8) throw e_8.error; }
998
+ }
999
+ }
1000
+ }
1001
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
1002
+ finally {
1003
+ try {
1004
+ if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
1005
+ }
1006
+ finally { if (e_7) throw e_7.error; }
1007
+ }
1008
+ };
1009
+ AcDbLibreDwgConverter.prototype.processTextObjectContextData = function (model, db) {
1010
+ var e_9, _a;
1011
+ var _b;
1012
+ var contexts = (_b = this.optionalObjectArray(model, 'TEXTOBJECTCONTEXTDATA')) !== null && _b !== void 0 ? _b : this.optionalObjectArray(model, 'ACDB_TEXTOBJECTCONTEXTDATA_CLASS');
1013
+ if (!(contexts === null || contexts === void 0 ? void 0 : contexts.length))
1014
+ return;
1015
+ var contextDict = db.objects.objectContextData;
1016
+ var objectConverter = new AcDbObjectConverter();
1017
+ try {
1018
+ for (var contexts_3 = __values(contexts), contexts_3_1 = contexts_3.next(); !contexts_3_1.done; contexts_3_1 = contexts_3.next()) {
1019
+ var context = contexts_3_1.value;
1020
+ var dbContext = objectConverter.convertTextObjectContextData(context);
1021
+ if (dbContext.objectId)
1022
+ contextDict.setAt(dbContext.objectId, dbContext);
1023
+ }
1024
+ }
1025
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
1026
+ finally {
1027
+ try {
1028
+ if (contexts_3_1 && !contexts_3_1.done && (_a = contexts_3.return)) _a.call(contexts_3);
1029
+ }
1030
+ finally { if (e_9) throw e_9.error; }
1031
+ }
1032
+ };
1033
+ AcDbLibreDwgConverter.prototype.processHatchScaleContextData = function (model, db) {
1034
+ var e_10, _a;
1035
+ var _b;
1036
+ var contexts = (_b = this.optionalObjectArray(model, 'HATCHSCALECONTEXTDATA')) !== null && _b !== void 0 ? _b : this.optionalObjectArray(model, 'ACDB_HATCHSCALECONTEXTDATA_CLASS');
1037
+ if (!(contexts === null || contexts === void 0 ? void 0 : contexts.length))
1038
+ return;
1039
+ var contextDict = db.objects.objectContextData;
1040
+ var objectConverter = new AcDbObjectConverter();
1041
+ try {
1042
+ for (var contexts_4 = __values(contexts), contexts_4_1 = contexts_4.next(); !contexts_4_1.done; contexts_4_1 = contexts_4.next()) {
1043
+ var context = contexts_4_1.value;
1044
+ var dbContext = objectConverter.convertHatchScaleContextData(context);
1045
+ if (dbContext.objectId)
1046
+ contextDict.setAt(dbContext.objectId, dbContext);
1047
+ }
1048
+ }
1049
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
1050
+ finally {
1051
+ try {
1052
+ if (contexts_4_1 && !contexts_4_1.done && (_a = contexts_4.return)) _a.call(contexts_4);
1053
+ }
1054
+ finally { if (e_10) throw e_10.error; }
1055
+ }
1056
+ };
1057
+ AcDbLibreDwgConverter.prototype.processBlkRefObjectContextData = function (model, db) {
1058
+ var e_11, _a;
1059
+ var _b;
1060
+ var contexts = (_b = this.optionalObjectArray(model, 'BLKREFOBJECTCONTEXTDATA')) !== null && _b !== void 0 ? _b : this.optionalObjectArray(model, 'ACDB_BLKREFOBJECTCONTEXTDATA_CLASS');
1061
+ if (!(contexts === null || contexts === void 0 ? void 0 : contexts.length))
1062
+ return;
1063
+ var contextDict = db.objects.objectContextData;
1064
+ var objectConverter = new AcDbObjectConverter();
1065
+ try {
1066
+ for (var contexts_5 = __values(contexts), contexts_5_1 = contexts_5.next(); !contexts_5_1.done; contexts_5_1 = contexts_5.next()) {
1067
+ var context = contexts_5_1.value;
1068
+ var dbContext = objectConverter.convertBlkRefObjectContextData(context);
1069
+ if (dbContext.objectId)
1070
+ contextDict.setAt(dbContext.objectId, dbContext);
1071
+ }
1072
+ }
1073
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
1074
+ finally {
1075
+ try {
1076
+ if (contexts_5_1 && !contexts_5_1.done && (_a = contexts_5.return)) _a.call(contexts_5);
1077
+ }
1078
+ finally { if (e_11) throw e_11.error; }
1079
+ }
1080
+ };
1081
+ AcDbLibreDwgConverter.prototype.processLeaderObjectContextData = function (model, db) {
1082
+ var e_12, _a;
1083
+ var _b;
1084
+ var contexts = (_b = this.optionalObjectArray(model, 'LEADEROBJECTCONTEXTDATA')) !== null && _b !== void 0 ? _b : this.optionalObjectArray(model, 'ACDB_LEADEROBJECTCONTEXTDATA_CLASS');
1085
+ if (!(contexts === null || contexts === void 0 ? void 0 : contexts.length))
1086
+ return;
1087
+ var contextDict = db.objects.objectContextData;
1088
+ var objectConverter = new AcDbObjectConverter();
1089
+ try {
1090
+ for (var contexts_6 = __values(contexts), contexts_6_1 = contexts_6.next(); !contexts_6_1.done; contexts_6_1 = contexts_6.next()) {
1091
+ var context = contexts_6_1.value;
1092
+ var dbContext = objectConverter.convertLeaderObjectContextData(context);
1093
+ if (dbContext.objectId)
1094
+ contextDict.setAt(dbContext.objectId, dbContext);
1095
+ }
1096
+ }
1097
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
1098
+ finally {
1099
+ try {
1100
+ if (contexts_6_1 && !contexts_6_1.done && (_a = contexts_6.return)) _a.call(contexts_6);
1101
+ }
1102
+ finally { if (e_12) throw e_12.error; }
1103
+ }
1104
+ };
1105
+ AcDbLibreDwgConverter.prototype.processMLeaderObjectContextData = function (model, db) {
1106
+ var e_13, _a;
1107
+ var _b;
1108
+ var contexts = (_b = this.optionalObjectArray(model, 'MLEADEROBJECTCONTEXTDATA')) !== null && _b !== void 0 ? _b : this.optionalObjectArray(model, 'ACDB_MLEADEROBJECTCONTEXTDATA_CLASS');
1109
+ if (!(contexts === null || contexts === void 0 ? void 0 : contexts.length))
1110
+ return;
1111
+ var contextDict = db.objects.objectContextData;
1112
+ var objectConverter = new AcDbObjectConverter();
1113
+ try {
1114
+ for (var contexts_7 = __values(contexts), contexts_7_1 = contexts_7.next(); !contexts_7_1.done; contexts_7_1 = contexts_7.next()) {
1115
+ var context = contexts_7_1.value;
1116
+ var dbContext = objectConverter.convertMLeaderObjectContextData(context);
1117
+ if (dbContext.objectId)
1118
+ contextDict.setAt(dbContext.objectId, dbContext);
1119
+ }
1120
+ }
1121
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
1122
+ finally {
1123
+ try {
1124
+ if (contexts_7_1 && !contexts_7_1.done && (_a = contexts_7.return)) _a.call(contexts_7);
1125
+ }
1126
+ finally { if (e_13) throw e_13.error; }
1127
+ }
1128
+ };
1129
+ AcDbLibreDwgConverter.prototype.processMTextAttributeObjectContextData = function (model, db) {
1130
+ var e_14, _a;
1131
+ var _b;
1132
+ var contexts = (_b = this.optionalObjectArray(model, 'MTEXTATTRIBUTEOBJECTCONTEXTDATA')) !== null && _b !== void 0 ? _b : this.optionalObjectArray(model, 'ACDB_MTEXTATTRIBUTEOBJECTCONTEXTDATA_CLASS');
1133
+ if (!(contexts === null || contexts === void 0 ? void 0 : contexts.length))
1134
+ return;
1135
+ var contextDict = db.objects.objectContextData;
1136
+ var objectConverter = new AcDbObjectConverter();
1137
+ try {
1138
+ for (var contexts_8 = __values(contexts), contexts_8_1 = contexts_8.next(); !contexts_8_1.done; contexts_8_1 = contexts_8.next()) {
1139
+ var context = contexts_8_1.value;
1140
+ var dbContext = objectConverter.convertMTextAttributeObjectContextData(context);
1141
+ if (dbContext.objectId)
1142
+ contextDict.setAt(dbContext.objectId, dbContext);
1143
+ }
1144
+ }
1145
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
1146
+ finally {
1147
+ try {
1148
+ if (contexts_8_1 && !contexts_8_1.done && (_a = contexts_8.return)) _a.call(contexts_8);
1149
+ }
1150
+ finally { if (e_14) throw e_14.error; }
875
1151
  }
876
1152
  };
877
1153
  AcDbLibreDwgConverter.prototype.processXRecords = function (model, db) {
878
- var e_6, _a;
1154
+ var e_15, _a;
879
1155
  var xrecords = model.objects.XRECORD;
880
1156
  if (!(xrecords === null || xrecords === void 0 ? void 0 : xrecords.length))
881
1157
  return;
@@ -889,12 +1165,12 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
889
1165
  xrecordDict.setAt(dbXrecord.objectId, dbXrecord);
890
1166
  }
891
1167
  }
892
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1168
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
893
1169
  finally {
894
1170
  try {
895
1171
  if (xrecords_1_1 && !xrecords_1_1.done && (_a = xrecords_1.return)) _a.call(xrecords_1);
896
1172
  }
897
- finally { if (e_6) throw e_6.error; }
1173
+ finally { if (e_15) throw e_15.error; }
898
1174
  }
899
1175
  };
900
1176
  /**
@@ -902,7 +1178,7 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
902
1178
  * dictionaries have been materialized.
903
1179
  */
904
1180
  AcDbLibreDwgConverter.prototype.finishCannoscale = function (model, db) {
905
- var e_7, _a;
1181
+ var e_16, _a;
906
1182
  var _b, _c;
907
1183
  var tryRead = function (variableDict) {
908
1184
  var cannoscaleVar = variableDict.getAt('CANNOSCALE');
@@ -943,12 +1219,57 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
943
1219
  return;
944
1220
  }
945
1221
  }
946
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
1222
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
947
1223
  finally {
948
1224
  try {
949
1225
  if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
950
1226
  }
951
- finally { if (e_7) throw e_7.error; }
1227
+ finally { if (e_16) throw e_16.error; }
1228
+ }
1229
+ };
1230
+ /**
1231
+ * Reads ANNOALLVISIBLE from AcDbVariableDictionary → DICTIONARYVAR.
1232
+ */
1233
+ AcDbLibreDwgConverter.prototype.finishAnnoallvisible = function (model, db) {
1234
+ var e_17, _a;
1235
+ var _b, _c;
1236
+ var tryRead = function (variableDict) {
1237
+ var annoVar = variableDict.getAt('ANNOALLVISIBLE');
1238
+ if (!(annoVar instanceof AcDbDictionaryVar) || annoVar.value == null) {
1239
+ return false;
1240
+ }
1241
+ var raw = String(annoVar.value).trim();
1242
+ db.annoallvisible = raw !== '0' && raw.toLowerCase() !== 'false';
1243
+ return true;
1244
+ };
1245
+ var fromRoot = db.objects.dictionary.getAt('AcDbVariableDictionary');
1246
+ if (fromRoot instanceof AcDbDictionary && tryRead(fromRoot))
1247
+ return;
1248
+ var normalize = function (handle) {
1249
+ return handle == null || handle === '' || handle === 0
1250
+ ? ''
1251
+ : String(handle).trim().toUpperCase();
1252
+ };
1253
+ try {
1254
+ for (var _d = __values((_b = model.objects.DICTIONARY) !== null && _b !== void 0 ? _b : []), _e = _d.next(); !_e.done; _e = _d.next()) {
1255
+ var dict = _e.value;
1256
+ var entries = (_c = dict.entries) !== null && _c !== void 0 ? _c : {};
1257
+ var childHandle = entries['AcDbVariableDictionary'];
1258
+ if (!childHandle)
1259
+ continue;
1260
+ var variableDict = db.getObjectById(normalize(childHandle));
1261
+ if (!(variableDict instanceof AcDbDictionary))
1262
+ continue;
1263
+ if (tryRead(variableDict))
1264
+ return;
1265
+ }
1266
+ }
1267
+ catch (e_17_1) { e_17 = { error: e_17_1 }; }
1268
+ finally {
1269
+ try {
1270
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
1271
+ }
1272
+ finally { if (e_17) throw e_17.error; }
952
1273
  }
953
1274
  };
954
1275
  /** Reads optional object arrays that newer libredwg-web builds may expose. */
@@ -977,7 +1298,7 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
977
1298
  * @returns A new array of entities grouped by their `type` property.
978
1299
  */
979
1300
  AcDbLibreDwgConverter.prototype.groupAndFlattenByType = function (entities) {
980
- var e_8, _a, e_9, _b;
1301
+ var e_18, _a, e_19, _b;
981
1302
  var groups = {};
982
1303
  var order = [];
983
1304
  try {
@@ -990,12 +1311,12 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
990
1311
  groups[entity.type].push(entity);
991
1312
  }
992
1313
  }
993
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
1314
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
994
1315
  finally {
995
1316
  try {
996
1317
  if (entities_1_1 && !entities_1_1.done && (_a = entities_1.return)) _a.call(entities_1);
997
1318
  }
998
- finally { if (e_8) throw e_8.error; }
1319
+ finally { if (e_18) throw e_18.error; }
999
1320
  }
1000
1321
  var result = [];
1001
1322
  try {
@@ -1008,12 +1329,12 @@ var AcDbLibreDwgConverter = /** @class */ (function (_super) {
1008
1329
  }
1009
1330
  }
1010
1331
  }
1011
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
1332
+ catch (e_19_1) { e_19 = { error: e_19_1 }; }
1012
1333
  finally {
1013
1334
  try {
1014
1335
  if (order_1_1 && !order_1_1.done && (_b = order_1.return)) _b.call(order_1);
1015
1336
  }
1016
- finally { if (e_9) throw e_9.error; }
1337
+ finally { if (e_19) throw e_19.error; }
1017
1338
  }
1018
1339
  return result;
1019
1340
  };