@mlightcad/libredwg-web 0.5.0 → 0.6.0
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.
- package/README.md +147 -147
- package/dist/libredwg-web.js +96 -34
- package/dist/libredwg-web.umd.cjs +95 -33
- package/lib/converter/converter.js +32 -21
- package/lib/converter/entityConverter.d.ts +2 -2
- package/lib/converter/entityConverter.js +30 -39
- package/lib/database/common.d.ts +2 -0
- package/lib/database/common.js +11 -0
- package/lib/database/entities/entity.d.ts +2 -2
- package/lib/database/tables/table.d.ts +2 -2
- package/package.json +1 -1
- package/wasm/libredwg-web.d.ts +523 -523
|
@@ -14,6 +14,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
14
14
|
const isPaperSpace = (name) => {
|
|
15
15
|
return name && name.toUpperCase().startsWith(MODEL_SPACE_PREFIX);
|
|
16
16
|
};
|
|
17
|
+
const idToString = (id) => {
|
|
18
|
+
return id.toString(16).toUpperCase();
|
|
19
|
+
};
|
|
20
|
+
const isValidPointer = (ptr) => {
|
|
21
|
+
if (typeof ptr === "bigint") {
|
|
22
|
+
return ptr !== 0n;
|
|
23
|
+
} else {
|
|
24
|
+
return ptr !== 0;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
17
27
|
var DwgCodePage = /* @__PURE__ */ ((DwgCodePage2) => {
|
|
18
28
|
DwgCodePage2[DwgCodePage2["CP_UTF8"] = 0] = "CP_UTF8";
|
|
19
29
|
DwgCodePage2[DwgCodePage2["CP_US_ASCII"] = 1] = "CP_US_ASCII";
|
|
@@ -6684,14 +6694,26 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6684
6694
|
const gridSpacing = libredwg.dwg_dynapi_entity_value(entity, "GRIDUNIT").data;
|
|
6685
6695
|
const viewDirection = libredwg.dwg_dynapi_entity_value(entity, "VIEWDIR").data;
|
|
6686
6696
|
const targetPoint = libredwg.dwg_dynapi_entity_value(entity, "view_target").data;
|
|
6687
|
-
const perspectiveLensLength = libredwg.dwg_dynapi_entity_value(
|
|
6697
|
+
const perspectiveLensLength = libredwg.dwg_dynapi_entity_value(
|
|
6698
|
+
entity,
|
|
6699
|
+
"lens_length"
|
|
6700
|
+
).data;
|
|
6688
6701
|
const frontClipZ = libredwg.dwg_dynapi_entity_value(entity, "front_clip_z").data;
|
|
6689
6702
|
const backClipZ = libredwg.dwg_dynapi_entity_value(entity, "back_clip_z").data;
|
|
6690
6703
|
const viewHeight = libredwg.dwg_dynapi_entity_value(entity, "VIEWSIZE").data;
|
|
6691
6704
|
const snapAngle = libredwg.dwg_dynapi_entity_value(entity, "SNAPANG").data;
|
|
6692
|
-
const viewTwistAngle = libredwg.dwg_dynapi_entity_value(
|
|
6693
|
-
|
|
6694
|
-
|
|
6705
|
+
const viewTwistAngle = libredwg.dwg_dynapi_entity_value(
|
|
6706
|
+
entity,
|
|
6707
|
+
"twist_angle"
|
|
6708
|
+
).data;
|
|
6709
|
+
const circleZoomPercent = libredwg.dwg_dynapi_entity_value(
|
|
6710
|
+
entity,
|
|
6711
|
+
"circle_zoom"
|
|
6712
|
+
).data;
|
|
6713
|
+
const statusBitFlags = libredwg.dwg_dynapi_entity_value(
|
|
6714
|
+
entity,
|
|
6715
|
+
"status_flag"
|
|
6716
|
+
).data;
|
|
6695
6717
|
const sheetName = libredwg.dwg_dynapi_entity_value(entity, "style_sheet").data;
|
|
6696
6718
|
const renderMode = libredwg.dwg_dynapi_entity_value(entity, "render_mode").data;
|
|
6697
6719
|
const ucsPerViewport = libredwg.dwg_dynapi_entity_value(entity, "UCSVP").data;
|
|
@@ -6702,19 +6724,40 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6702
6724
|
const ucsId = libredwg.dwg_ref_get_absref(named_ucs_ref);
|
|
6703
6725
|
const base_ucs_ref = libredwg.dwg_dynapi_entity_value(entity, "base_ucs").data;
|
|
6704
6726
|
const ucsBaseId = libredwg.dwg_ref_get_absref(base_ucs_ref);
|
|
6705
|
-
const orthographicType = libredwg.dwg_dynapi_entity_value(
|
|
6727
|
+
const orthographicType = libredwg.dwg_dynapi_entity_value(
|
|
6728
|
+
entity,
|
|
6729
|
+
"UCSORTHOVIEW"
|
|
6730
|
+
).data;
|
|
6706
6731
|
const elevation = libredwg.dwg_dynapi_entity_value(entity, "ucs_elevation").data;
|
|
6707
|
-
const shadePlotMode = libredwg.dwg_dynapi_entity_value(
|
|
6708
|
-
|
|
6709
|
-
|
|
6732
|
+
const shadePlotMode = libredwg.dwg_dynapi_entity_value(
|
|
6733
|
+
entity,
|
|
6734
|
+
"shadeplot_mode"
|
|
6735
|
+
).data;
|
|
6736
|
+
const isDefaultLighting = libredwg.dwg_dynapi_entity_value(
|
|
6737
|
+
entity,
|
|
6738
|
+
"use_default_lights"
|
|
6739
|
+
).data;
|
|
6740
|
+
const defaultLightingType = libredwg.dwg_dynapi_entity_value(
|
|
6741
|
+
entity,
|
|
6742
|
+
"default_lighting_type"
|
|
6743
|
+
).data;
|
|
6710
6744
|
const brightness = libredwg.dwg_dynapi_entity_value(entity, "brightness").data;
|
|
6711
6745
|
const contrast = libredwg.dwg_dynapi_entity_value(entity, "contrast").data;
|
|
6712
|
-
const majorGridFrequency = libredwg.dwg_dynapi_entity_value(
|
|
6713
|
-
|
|
6746
|
+
const majorGridFrequency = libredwg.dwg_dynapi_entity_value(
|
|
6747
|
+
entity,
|
|
6748
|
+
"grid_major"
|
|
6749
|
+
).data;
|
|
6750
|
+
const background_ref = libredwg.dwg_dynapi_entity_value(
|
|
6751
|
+
entity,
|
|
6752
|
+
"background"
|
|
6753
|
+
).data;
|
|
6714
6754
|
const backgroundId = libredwg.dwg_ref_get_absref(background_ref);
|
|
6715
6755
|
const shadeplot_ref = libredwg.dwg_dynapi_entity_value(entity, "shadeplot").data;
|
|
6716
6756
|
const shadePlotId = libredwg.dwg_ref_get_absref(shadeplot_ref);
|
|
6717
|
-
const visualstyle_ref = libredwg.dwg_dynapi_entity_value(
|
|
6757
|
+
const visualstyle_ref = libredwg.dwg_dynapi_entity_value(
|
|
6758
|
+
entity,
|
|
6759
|
+
"visualstyle"
|
|
6760
|
+
).data;
|
|
6718
6761
|
const visualStyleId = libredwg.dwg_ref_get_absref(visualstyle_ref);
|
|
6719
6762
|
const sun_ref = libredwg.dwg_dynapi_entity_value(entity, "sun").data;
|
|
6720
6763
|
const sunId = libredwg.dwg_ref_get_absref(sun_ref);
|
|
@@ -6746,20 +6789,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6746
6789
|
ucsOrigin,
|
|
6747
6790
|
ucsXAxis,
|
|
6748
6791
|
ucsYAxis,
|
|
6749
|
-
ucsId: ucsId
|
|
6750
|
-
ucsBaseId: ucsBaseId
|
|
6792
|
+
ucsId: idToString(ucsId),
|
|
6793
|
+
ucsBaseId: idToString(ucsBaseId),
|
|
6751
6794
|
orthographicType,
|
|
6752
6795
|
elevation,
|
|
6753
6796
|
shadePlotMode,
|
|
6754
6797
|
majorGridFrequency,
|
|
6755
|
-
backgroundId: backgroundId
|
|
6756
|
-
shadePlotId: shadePlotId
|
|
6757
|
-
visualStyleId: visualStyleId
|
|
6798
|
+
backgroundId: idToString(backgroundId),
|
|
6799
|
+
shadePlotId: idToString(shadePlotId),
|
|
6800
|
+
visualStyleId: idToString(visualStyleId),
|
|
6758
6801
|
isDefaultLighting: !!isDefaultLighting,
|
|
6759
6802
|
defaultLightingType,
|
|
6760
6803
|
brightness,
|
|
6761
6804
|
contrast,
|
|
6762
|
-
sunId: sunId
|
|
6805
|
+
sunId: idToString(sunId)
|
|
6763
6806
|
};
|
|
6764
6807
|
}
|
|
6765
6808
|
convertWipeout(entity, commonAttrs) {
|
|
@@ -6896,8 +6939,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6896
6939
|
const lineTypeScale = libredwg.dwg_object_entity_get_ltype_scale(entity);
|
|
6897
6940
|
const isVisible = !libredwg.dwg_object_entity_get_invisible(entity);
|
|
6898
6941
|
return {
|
|
6899
|
-
handle: handle.value,
|
|
6900
|
-
ownerBlockRecordSoftId: ownerhandle.absolute_ref,
|
|
6942
|
+
handle: idToString(handle.value),
|
|
6943
|
+
ownerBlockRecordSoftId: idToString(ownerhandle.absolute_ref),
|
|
6901
6944
|
layer,
|
|
6902
6945
|
color: rgbColor,
|
|
6903
6946
|
colorIndex,
|
|
@@ -6913,13 +6956,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6913
6956
|
getLayerName(entity) {
|
|
6914
6957
|
const libredwg = this.libredwg;
|
|
6915
6958
|
const layer = libredwg.dwg_object_entity_get_layer_object_ref(entity);
|
|
6916
|
-
const name = this.layers.get(layer.handleref.value);
|
|
6959
|
+
const name = this.layers.get(idToString(layer.handleref.value));
|
|
6917
6960
|
return name ?? "0";
|
|
6918
6961
|
}
|
|
6919
6962
|
getLtypeName(entity) {
|
|
6920
6963
|
const libredwg = this.libredwg;
|
|
6921
6964
|
const ltype = libredwg.dwg_object_entity_get_ltype_object_ref(entity);
|
|
6922
|
-
const name = this.ltypes.get(ltype.handleref.value);
|
|
6965
|
+
const name = this.ltypes.get(idToString(ltype.handleref.value));
|
|
6923
6966
|
return name ?? "";
|
|
6924
6967
|
}
|
|
6925
6968
|
}
|
|
@@ -7096,7 +7139,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7096
7139
|
let entities = this.convertEntities(obj, commonAttrs.handle);
|
|
7097
7140
|
if (entities.length == 0) {
|
|
7098
7141
|
const entities_ptr = libredwg.dwg_dynapi_entity_value(item, "entities").data;
|
|
7099
|
-
const object_ref_ptr_array = libredwg.dwg_ptr_to_object_ref_ptr_array(
|
|
7142
|
+
const object_ref_ptr_array = libredwg.dwg_ptr_to_object_ref_ptr_array(
|
|
7143
|
+
entities_ptr,
|
|
7144
|
+
num_owned
|
|
7145
|
+
);
|
|
7100
7146
|
const converter = this.entityConverter;
|
|
7101
7147
|
entities = [];
|
|
7102
7148
|
for (let index = 0; index < num_owned; index++) {
|
|
@@ -7458,9 +7504,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7458
7504
|
const elevation = libredwg.dwg_dynapi_entity_value(item, "ucs_elevation").data;
|
|
7459
7505
|
const majorGridLines = libredwg.dwg_dynapi_entity_value(item, "grid_major").data;
|
|
7460
7506
|
const background = libredwg.dwg_dynapi_entity_value(item, "background").data;
|
|
7461
|
-
const backgroundObjectId = background ? libredwg.dwg_ref_get_absref(background)
|
|
7507
|
+
const backgroundObjectId = background ? idToString(libredwg.dwg_ref_get_absref(background)) : void 0;
|
|
7462
7508
|
const visualstyle = libredwg.dwg_dynapi_entity_value(item, "visualstyle").data;
|
|
7463
|
-
const visualStyleObjectId = visualstyle ? libredwg.dwg_ref_get_absref(visualstyle)
|
|
7509
|
+
const visualStyleObjectId = visualstyle ? idToString(libredwg.dwg_ref_get_absref(visualstyle)) : void 0;
|
|
7464
7510
|
return {
|
|
7465
7511
|
...commonAttrs,
|
|
7466
7512
|
standardFlag,
|
|
@@ -7512,8 +7558,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7512
7558
|
const ownerhandle = libredwg.dwg_object_object_get_ownerhandle_object(object_tio);
|
|
7513
7559
|
const handle = libredwg.dwg_object_get_handle_object(obj);
|
|
7514
7560
|
return {
|
|
7515
|
-
handle: handle.value,
|
|
7516
|
-
ownerHandle: ownerhandle.absolute_ref,
|
|
7561
|
+
handle: idToString(handle.value),
|
|
7562
|
+
ownerHandle: idToString(ownerhandle.absolute_ref),
|
|
7517
7563
|
name: libredwg.dwg_dynapi_entity_value(tio, "name").data
|
|
7518
7564
|
};
|
|
7519
7565
|
}
|
|
@@ -7553,6 +7599,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7553
7599
|
const minExtent = libredwg.dwg_dynapi_entity_value(item, "EXTMIN").data;
|
|
7554
7600
|
const maxExtent = libredwg.dwg_dynapi_entity_value(item, "EXTMAX").data;
|
|
7555
7601
|
const elevation = libredwg.dwg_dynapi_entity_value(item, "ucs_elevation").data;
|
|
7602
|
+
const block_header_ref = libredwg.dwg_dynapi_entity_value(
|
|
7603
|
+
item,
|
|
7604
|
+
"block_header"
|
|
7605
|
+
).data;
|
|
7606
|
+
const paperSpaceTableId = idToString(
|
|
7607
|
+
libredwg.dwg_ref_get_absref(block_header_ref)
|
|
7608
|
+
);
|
|
7609
|
+
const active_viewport_ref = libredwg.dwg_dynapi_entity_value(
|
|
7610
|
+
item,
|
|
7611
|
+
"active_viewport"
|
|
7612
|
+
).data;
|
|
7613
|
+
const viewportId = idToString(
|
|
7614
|
+
libredwg.dwg_ref_get_absref(active_viewport_ref)
|
|
7615
|
+
);
|
|
7616
|
+
const named_ucs_ref = libredwg.dwg_dynapi_entity_value(item, "named_ucs").data;
|
|
7617
|
+
const namedUcsId = isValidPointer(named_ucs_ref) ? idToString(libredwg.dwg_ref_get_absref(named_ucs_ref)) : void 0;
|
|
7556
7618
|
return {
|
|
7557
7619
|
...commonAttrs,
|
|
7558
7620
|
layoutName,
|
|
@@ -7568,11 +7630,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7568
7630
|
ucsXAxis,
|
|
7569
7631
|
ucsYAxis,
|
|
7570
7632
|
orthographicType,
|
|
7571
|
-
paperSpaceTableId
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
// TODO: Set the correct value
|
|
7575
|
-
// namedUcsId?: string;
|
|
7633
|
+
paperSpaceTableId,
|
|
7634
|
+
viewportId,
|
|
7635
|
+
namedUcsId,
|
|
7576
7636
|
// orthographicUcsId?: string;
|
|
7577
7637
|
shadePlotId: ""
|
|
7578
7638
|
// TODO: Set the correct value
|
|
@@ -9065,8 +9125,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
9065
9125
|
return converter.convert(data);
|
|
9066
9126
|
}
|
|
9067
9127
|
/**
|
|
9068
|
-
* Converts Dwg_Data instance to DwgDatabase instance and returns conversion statistics.
|
|
9069
|
-
* DwgDatabase instance doesn't depend on Dwg_Data instance any more after conversion.
|
|
9128
|
+
* Converts Dwg_Data instance to DwgDatabase instance and returns conversion statistics.
|
|
9129
|
+
* DwgDatabase instance doesn't depend on Dwg_Data instance any more after conversion.
|
|
9070
9130
|
* So you can call function dwg_free to free memory occupied by Dwg_Data.
|
|
9071
9131
|
* @param data Pointer to Dwg_Data instance.
|
|
9072
9132
|
* @returns Returns the converted DwgDatabase and conversion statistics.
|
|
@@ -9989,7 +10049,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
9989
10049
|
exports2.createModule = createModule;
|
|
9990
10050
|
exports2.dwgCodePageToEncoding = dwgCodePageToEncoding;
|
|
9991
10051
|
exports2.dwgVersions = dwgVersions;
|
|
10052
|
+
exports2.idToString = idToString;
|
|
9992
10053
|
exports2.isModelSpace = isModelSpace;
|
|
9993
10054
|
exports2.isPaperSpace = isPaperSpace;
|
|
10055
|
+
exports2.isValidPointer = isValidPointer;
|
|
9994
10056
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
9995
10057
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HEADER_VARIABLES, isModelSpace, isPaperSpace } from '../database';
|
|
1
|
+
import { HEADER_VARIABLES, idToString, isModelSpace, isPaperSpace, isValidPointer } from '../database';
|
|
2
2
|
import { Dwg_Object_Type } from '../types';
|
|
3
3
|
import { LibreEntityConverter } from './entityConverter';
|
|
4
4
|
/**
|
|
@@ -153,7 +153,7 @@ export class LibreDwgConverter {
|
|
|
153
153
|
wasAProxyFlag: cls.s_zombie,
|
|
154
154
|
// DWG_TYPE_PROXY_ENTITY = 0x1F2 /* 498 */,
|
|
155
155
|
// DWG_TYPE_PROXY_OBJECT = 0x1F3 /* 499 */,
|
|
156
|
-
isAnEntityFlag: cls.item_class_id ===
|
|
156
|
+
isAnEntityFlag: cls.item_class_id === 0x1f2
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
}
|
|
@@ -167,7 +167,8 @@ export class LibreDwgConverter {
|
|
|
167
167
|
commonAttrs.name = block.name;
|
|
168
168
|
}
|
|
169
169
|
// The number of entities
|
|
170
|
-
const num_owned = libredwg.dwg_dynapi_entity_value(item, 'num_owned')
|
|
170
|
+
const num_owned = libredwg.dwg_dynapi_entity_value(item, 'num_owned')
|
|
171
|
+
.data;
|
|
171
172
|
const flags = libredwg.dwg_dynapi_entity_value(item, 'flag').data;
|
|
172
173
|
const description = libredwg.dwg_dynapi_entity_value(item, 'description')
|
|
173
174
|
.data;
|
|
@@ -198,7 +199,8 @@ export class LibreDwgConverter {
|
|
|
198
199
|
// on libredwg too. In this time, I try to use property 'entities' of block header to iterate entities.
|
|
199
200
|
let entities = this.convertEntities(obj, commonAttrs.handle);
|
|
200
201
|
if (entities.length == 0) {
|
|
201
|
-
const entities_ptr = libredwg.dwg_dynapi_entity_value(item, 'entities')
|
|
202
|
+
const entities_ptr = libredwg.dwg_dynapi_entity_value(item, 'entities')
|
|
203
|
+
.data;
|
|
202
204
|
const object_ref_ptr_array = libredwg.dwg_ptr_to_object_ref_ptr_array(entities_ptr, num_owned);
|
|
203
205
|
const converter = this.entityConverter;
|
|
204
206
|
entities = [];
|
|
@@ -510,13 +512,13 @@ export class LibreDwgConverter {
|
|
|
510
512
|
// - 0xc8 for none (also c3 and rgb of 0x101)
|
|
511
513
|
const method = color.method;
|
|
512
514
|
let colorIndex = 256;
|
|
513
|
-
let rgbColor =
|
|
515
|
+
let rgbColor = 0xffffff;
|
|
514
516
|
// It looks like that libredwg always returns 256 for property 'index' in Dwg_Color
|
|
515
|
-
if (method ===
|
|
516
|
-
colorIndex = color.rgb &
|
|
517
|
+
if (method === 0xc3 || ((color.rgb >>> 24) & 0xff) === 0xc3) {
|
|
518
|
+
colorIndex = color.rgb & 0x000000ff;
|
|
517
519
|
}
|
|
518
|
-
else if (method ==
|
|
519
|
-
rgbColor = color.rgb &
|
|
520
|
+
else if (method == 0xc2 || ((color.rgb >>> 24) & 0xff) === 0xc2) {
|
|
521
|
+
rgbColor = color.rgb & 0x00ffffff;
|
|
520
522
|
}
|
|
521
523
|
return {
|
|
522
524
|
...commonAttrs,
|
|
@@ -546,8 +548,11 @@ export class LibreDwgConverter {
|
|
|
546
548
|
.data;
|
|
547
549
|
const patternLen = libredwg.dwg_dynapi_entity_value(item, 'pattern_len')
|
|
548
550
|
.data;
|
|
549
|
-
const dashes = libredwg.dwg_dynapi_entity_value(item, 'dashes')
|
|
550
|
-
|
|
551
|
+
const dashes = libredwg.dwg_dynapi_entity_value(item, 'dashes')
|
|
552
|
+
.data;
|
|
553
|
+
const dashArray = dashes
|
|
554
|
+
? libredwg.dwg_ptr_to_ltype_dash_array(dashes, numDashes)
|
|
555
|
+
: [];
|
|
551
556
|
return {
|
|
552
557
|
...commonAttrs,
|
|
553
558
|
description: description,
|
|
@@ -667,12 +672,12 @@ export class LibreDwgConverter {
|
|
|
667
672
|
const background = libredwg.dwg_dynapi_entity_value(item, 'background')
|
|
668
673
|
.data;
|
|
669
674
|
const backgroundObjectId = background
|
|
670
|
-
? libredwg.dwg_ref_get_absref(background)
|
|
675
|
+
? idToString(libredwg.dwg_ref_get_absref(background))
|
|
671
676
|
: undefined;
|
|
672
677
|
const visualstyle = libredwg.dwg_dynapi_entity_value(item, 'visualstyle')
|
|
673
678
|
.data;
|
|
674
679
|
const visualStyleObjectId = visualstyle
|
|
675
|
-
? libredwg.dwg_ref_get_absref(visualstyle)
|
|
680
|
+
? idToString(libredwg.dwg_ref_get_absref(visualstyle))
|
|
676
681
|
: undefined;
|
|
677
682
|
// BITCODE_B UCSFOLLOW;
|
|
678
683
|
// BITCODE_B FASTZOOM;
|
|
@@ -734,8 +739,8 @@ export class LibreDwgConverter {
|
|
|
734
739
|
const ownerhandle = libredwg.dwg_object_object_get_ownerhandle_object(object_tio);
|
|
735
740
|
const handle = libredwg.dwg_object_get_handle_object(obj);
|
|
736
741
|
return {
|
|
737
|
-
handle: handle.value,
|
|
738
|
-
ownerHandle: ownerhandle.absolute_ref,
|
|
742
|
+
handle: idToString(handle.value),
|
|
743
|
+
ownerHandle: idToString(ownerhandle.absolute_ref),
|
|
739
744
|
name: libredwg.dwg_dynapi_entity_value(tio, 'name').data
|
|
740
745
|
};
|
|
741
746
|
}
|
|
@@ -791,10 +796,16 @@ export class LibreDwgConverter {
|
|
|
791
796
|
.data;
|
|
792
797
|
const elevation = libredwg.dwg_dynapi_entity_value(item, 'ucs_elevation')
|
|
793
798
|
.data;
|
|
794
|
-
|
|
795
|
-
|
|
799
|
+
const block_header_ref = libredwg.dwg_dynapi_entity_value(item, 'block_header').data;
|
|
800
|
+
const paperSpaceTableId = idToString(libredwg.dwg_ref_get_absref(block_header_ref));
|
|
801
|
+
const active_viewport_ref = libredwg.dwg_dynapi_entity_value(item, 'active_viewport').data;
|
|
802
|
+
const viewportId = idToString(libredwg.dwg_ref_get_absref(active_viewport_ref));
|
|
803
|
+
const named_ucs_ref = libredwg.dwg_dynapi_entity_value(item, 'named_ucs')
|
|
804
|
+
.data;
|
|
805
|
+
const namedUcsId = isValidPointer(named_ucs_ref)
|
|
806
|
+
? idToString(libredwg.dwg_ref_get_absref(named_ucs_ref))
|
|
807
|
+
: undefined;
|
|
796
808
|
// BITCODE_H base_ucs;
|
|
797
|
-
// BITCODE_H named_ucs;
|
|
798
809
|
// BITCODE_BL num_viewports; // r2004+
|
|
799
810
|
// BITCODE_H *viewports; // r2004+
|
|
800
811
|
return {
|
|
@@ -812,9 +823,9 @@ export class LibreDwgConverter {
|
|
|
812
823
|
ucsXAxis: ucsXAxis,
|
|
813
824
|
ucsYAxis: ucsYAxis,
|
|
814
825
|
orthographicType: orthographicType,
|
|
815
|
-
paperSpaceTableId:
|
|
816
|
-
viewportId:
|
|
817
|
-
|
|
826
|
+
paperSpaceTableId: paperSpaceTableId,
|
|
827
|
+
viewportId: viewportId,
|
|
828
|
+
namedUcsId: namedUcsId,
|
|
818
829
|
// orthographicUcsId?: string;
|
|
819
830
|
shadePlotId: '' // TODO: Set the correct value
|
|
820
831
|
};
|
|
@@ -3,8 +3,8 @@ import { LibreDwgEx } from '../libredwg';
|
|
|
3
3
|
import { Dwg_Object_Ptr } from '../types';
|
|
4
4
|
export declare class LibreEntityConverter {
|
|
5
5
|
libredwg: LibreDwgEx;
|
|
6
|
-
layers: Map<
|
|
7
|
-
ltypes: Map<
|
|
6
|
+
layers: Map<string, string>;
|
|
7
|
+
ltypes: Map<string, string>;
|
|
8
8
|
unknownEntityCount: number;
|
|
9
9
|
constructor(instance: LibreDwgEx);
|
|
10
10
|
prepare(db: DwgDatabase, force?: boolean): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DwgBoundaryPathEdgeType, DwgHatchAssociativity, DwgHatchSolidFill } from '../database';
|
|
1
|
+
import { DwgBoundaryPathEdgeType, DwgHatchAssociativity, DwgHatchSolidFill, idToString } from '../database';
|
|
2
2
|
import { Dwg_Hatch_Edge_Type, Dwg_Object_Type } from '../types';
|
|
3
3
|
export class LibreEntityConverter {
|
|
4
4
|
libredwg;
|
|
@@ -957,7 +957,8 @@ export class LibreEntityConverter {
|
|
|
957
957
|
convertPolyline2d(entity, commonAttrs, object) {
|
|
958
958
|
const libredwg = this.libredwg;
|
|
959
959
|
const flag = libredwg.dwg_dynapi_entity_value(entity, 'flag').data;
|
|
960
|
-
const smoothType = libredwg.dwg_dynapi_entity_value(entity, 'curve_type')
|
|
960
|
+
const smoothType = libredwg.dwg_dynapi_entity_value(entity, 'curve_type')
|
|
961
|
+
.data;
|
|
961
962
|
const startWidth = libredwg.dwg_dynapi_entity_value(entity, 'start_width')
|
|
962
963
|
.data;
|
|
963
964
|
const endWidth = libredwg.dwg_dynapi_entity_value(entity, 'end_width')
|
|
@@ -993,13 +994,14 @@ export class LibreEntityConverter {
|
|
|
993
994
|
meshMVertexCount: 0,
|
|
994
995
|
meshNVertexCount: 0,
|
|
995
996
|
surfaceMDensity: 0,
|
|
996
|
-
surfaceNDensity: 0
|
|
997
|
+
surfaceNDensity: 0
|
|
997
998
|
};
|
|
998
999
|
}
|
|
999
1000
|
convertPolyline3d(entity, commonAttrs, object) {
|
|
1000
1001
|
const libredwg = this.libredwg;
|
|
1001
1002
|
const flag = libredwg.dwg_dynapi_entity_value(entity, 'flag').data;
|
|
1002
|
-
const smoothType = libredwg.dwg_dynapi_entity_value(entity, 'curve_type')
|
|
1003
|
+
const smoothType = libredwg.dwg_dynapi_entity_value(entity, 'curve_type')
|
|
1004
|
+
.data;
|
|
1003
1005
|
const startWidth = libredwg.dwg_dynapi_entity_value(entity, 'start_width')
|
|
1004
1006
|
.data;
|
|
1005
1007
|
const endWidth = libredwg.dwg_dynapi_entity_value(entity, 'end_width')
|
|
@@ -1343,24 +1345,20 @@ export class LibreEntityConverter {
|
|
|
1343
1345
|
.data;
|
|
1344
1346
|
const targetPoint = libredwg.dwg_dynapi_entity_value(entity, 'view_target')
|
|
1345
1347
|
.data;
|
|
1346
|
-
const perspectiveLensLength = libredwg.dwg_dynapi_entity_value(entity, 'lens_length')
|
|
1347
|
-
.data;
|
|
1348
|
+
const perspectiveLensLength = libredwg.dwg_dynapi_entity_value(entity, 'lens_length').data;
|
|
1348
1349
|
const frontClipZ = libredwg.dwg_dynapi_entity_value(entity, 'front_clip_z')
|
|
1349
1350
|
.data;
|
|
1350
1351
|
const backClipZ = libredwg.dwg_dynapi_entity_value(entity, 'back_clip_z')
|
|
1351
1352
|
.data;
|
|
1352
|
-
// TODO: I am not sure whether view size in libredwg represents view height
|
|
1353
|
+
// TODO: I am not sure whether view size in libredwg represents view height
|
|
1353
1354
|
const viewHeight = libredwg.dwg_dynapi_entity_value(entity, 'VIEWSIZE')
|
|
1354
1355
|
.data;
|
|
1355
1356
|
const snapAngle = libredwg.dwg_dynapi_entity_value(entity, 'SNAPANG')
|
|
1356
1357
|
.data;
|
|
1357
|
-
const viewTwistAngle = libredwg.dwg_dynapi_entity_value(entity, 'twist_angle')
|
|
1358
|
-
|
|
1359
|
-
const circleZoomPercent = libredwg.dwg_dynapi_entity_value(entity, 'circle_zoom')
|
|
1360
|
-
.data;
|
|
1358
|
+
const viewTwistAngle = libredwg.dwg_dynapi_entity_value(entity, 'twist_angle').data;
|
|
1359
|
+
const circleZoomPercent = libredwg.dwg_dynapi_entity_value(entity, 'circle_zoom').data;
|
|
1361
1360
|
// TODO: convert frozenLayerIds and clippingBoundaryId
|
|
1362
|
-
const statusBitFlags = libredwg.dwg_dynapi_entity_value(entity, 'status_flag')
|
|
1363
|
-
.data;
|
|
1361
|
+
const statusBitFlags = libredwg.dwg_dynapi_entity_value(entity, 'status_flag').data;
|
|
1364
1362
|
const sheetName = libredwg.dwg_dynapi_entity_value(entity, 'style_sheet')
|
|
1365
1363
|
.data;
|
|
1366
1364
|
const renderMode = libredwg.dwg_dynapi_entity_value(entity, 'render_mode')
|
|
@@ -1381,30 +1379,23 @@ export class LibreEntityConverter {
|
|
|
1381
1379
|
.data;
|
|
1382
1380
|
const ucsBaseId = libredwg.dwg_ref_get_absref(base_ucs_ref);
|
|
1383
1381
|
// TODO: Not sure whether UCSORTHOVIEW represents orthographicType
|
|
1384
|
-
const orthographicType = libredwg.dwg_dynapi_entity_value(entity, 'UCSORTHOVIEW')
|
|
1385
|
-
.data;
|
|
1382
|
+
const orthographicType = libredwg.dwg_dynapi_entity_value(entity, 'UCSORTHOVIEW').data;
|
|
1386
1383
|
const elevation = libredwg.dwg_dynapi_entity_value(entity, 'ucs_elevation')
|
|
1387
1384
|
.data;
|
|
1388
|
-
const shadePlotMode = libredwg.dwg_dynapi_entity_value(entity, 'shadeplot_mode')
|
|
1389
|
-
|
|
1390
|
-
const
|
|
1391
|
-
.data;
|
|
1392
|
-
const defaultLightingType = libredwg.dwg_dynapi_entity_value(entity, 'default_lighting_type')
|
|
1393
|
-
.data;
|
|
1385
|
+
const shadePlotMode = libredwg.dwg_dynapi_entity_value(entity, 'shadeplot_mode').data;
|
|
1386
|
+
const isDefaultLighting = libredwg.dwg_dynapi_entity_value(entity, 'use_default_lights').data;
|
|
1387
|
+
const defaultLightingType = libredwg.dwg_dynapi_entity_value(entity, 'default_lighting_type').data;
|
|
1394
1388
|
const brightness = libredwg.dwg_dynapi_entity_value(entity, 'brightness')
|
|
1395
1389
|
.data;
|
|
1396
1390
|
const contrast = libredwg.dwg_dynapi_entity_value(entity, 'contrast')
|
|
1397
1391
|
.data;
|
|
1398
|
-
const majorGridFrequency = libredwg.dwg_dynapi_entity_value(entity, 'grid_major')
|
|
1399
|
-
|
|
1400
|
-
const background_ref = libredwg.dwg_dynapi_entity_value(entity, 'background')
|
|
1401
|
-
.data;
|
|
1392
|
+
const majorGridFrequency = libredwg.dwg_dynapi_entity_value(entity, 'grid_major').data;
|
|
1393
|
+
const background_ref = libredwg.dwg_dynapi_entity_value(entity, 'background').data;
|
|
1402
1394
|
const backgroundId = libredwg.dwg_ref_get_absref(background_ref);
|
|
1403
1395
|
const shadeplot_ref = libredwg.dwg_dynapi_entity_value(entity, 'shadeplot')
|
|
1404
1396
|
.data;
|
|
1405
1397
|
const shadePlotId = libredwg.dwg_ref_get_absref(shadeplot_ref);
|
|
1406
|
-
const visualstyle_ref = libredwg.dwg_dynapi_entity_value(entity, 'visualstyle')
|
|
1407
|
-
.data;
|
|
1398
|
+
const visualstyle_ref = libredwg.dwg_dynapi_entity_value(entity, 'visualstyle').data;
|
|
1408
1399
|
const visualStyleId = libredwg.dwg_ref_get_absref(visualstyle_ref);
|
|
1409
1400
|
// TODO: convert ambientLightColor
|
|
1410
1401
|
const sun_ref = libredwg.dwg_dynapi_entity_value(entity, 'sun')
|
|
@@ -1438,20 +1429,20 @@ export class LibreEntityConverter {
|
|
|
1438
1429
|
ucsOrigin: ucsOrigin,
|
|
1439
1430
|
ucsXAxis: ucsXAxis,
|
|
1440
1431
|
ucsYAxis: ucsYAxis,
|
|
1441
|
-
ucsId: ucsId
|
|
1442
|
-
ucsBaseId: ucsBaseId
|
|
1432
|
+
ucsId: idToString(ucsId),
|
|
1433
|
+
ucsBaseId: idToString(ucsBaseId),
|
|
1443
1434
|
orthographicType: orthographicType,
|
|
1444
1435
|
elevation: elevation,
|
|
1445
1436
|
shadePlotMode: shadePlotMode,
|
|
1446
1437
|
majorGridFrequency: majorGridFrequency,
|
|
1447
|
-
backgroundId: backgroundId
|
|
1448
|
-
shadePlotId: shadePlotId
|
|
1449
|
-
visualStyleId: visualStyleId
|
|
1438
|
+
backgroundId: idToString(backgroundId),
|
|
1439
|
+
shadePlotId: idToString(shadePlotId),
|
|
1440
|
+
visualStyleId: idToString(visualStyleId),
|
|
1450
1441
|
isDefaultLighting: !!isDefaultLighting,
|
|
1451
1442
|
defaultLightingType: defaultLightingType,
|
|
1452
1443
|
brightness: brightness,
|
|
1453
1444
|
contrast: contrast,
|
|
1454
|
-
sunId: sunId
|
|
1445
|
+
sunId: idToString(sunId)
|
|
1455
1446
|
};
|
|
1456
1447
|
}
|
|
1457
1448
|
convertWipeout(entity, commonAttrs) {
|
|
@@ -1574,8 +1565,8 @@ export class LibreEntityConverter {
|
|
|
1574
1565
|
const method = color.method;
|
|
1575
1566
|
let colorIndex = color.index;
|
|
1576
1567
|
let rgbColor = undefined;
|
|
1577
|
-
if (method ==
|
|
1578
|
-
rgbColor = color.rgb &
|
|
1568
|
+
if (method == 0xc2 || ((color.rgb >>> 24) & 0xff) === 0xc2) {
|
|
1569
|
+
rgbColor = color.rgb & 0x00ffffff;
|
|
1579
1570
|
}
|
|
1580
1571
|
const layer = this.getLayerName(entity);
|
|
1581
1572
|
const handle = libredwg.dwg_object_entity_get_handle_object(entity);
|
|
@@ -1585,8 +1576,8 @@ export class LibreEntityConverter {
|
|
|
1585
1576
|
const lineTypeScale = libredwg.dwg_object_entity_get_ltype_scale(entity);
|
|
1586
1577
|
const isVisible = !libredwg.dwg_object_entity_get_invisible(entity);
|
|
1587
1578
|
return {
|
|
1588
|
-
handle: handle.value,
|
|
1589
|
-
ownerBlockRecordSoftId: ownerhandle.absolute_ref,
|
|
1579
|
+
handle: idToString(handle.value),
|
|
1580
|
+
ownerBlockRecordSoftId: idToString(ownerhandle.absolute_ref),
|
|
1590
1581
|
layer: layer,
|
|
1591
1582
|
color: rgbColor,
|
|
1592
1583
|
colorIndex: colorIndex,
|
|
@@ -1602,13 +1593,13 @@ export class LibreEntityConverter {
|
|
|
1602
1593
|
getLayerName(entity) {
|
|
1603
1594
|
const libredwg = this.libredwg;
|
|
1604
1595
|
const layer = libredwg.dwg_object_entity_get_layer_object_ref(entity);
|
|
1605
|
-
const name = this.layers.get(layer.handleref.value);
|
|
1596
|
+
const name = this.layers.get(idToString(layer.handleref.value));
|
|
1606
1597
|
return name ?? '0';
|
|
1607
1598
|
}
|
|
1608
1599
|
getLtypeName(entity) {
|
|
1609
1600
|
const libredwg = this.libredwg;
|
|
1610
1601
|
const ltype = libredwg.dwg_object_entity_get_ltype_object_ref(entity);
|
|
1611
|
-
const name = this.ltypes.get(ltype.handleref.value);
|
|
1602
|
+
const name = this.ltypes.get(idToString(ltype.handleref.value));
|
|
1612
1603
|
return name ?? '';
|
|
1613
1604
|
}
|
|
1614
1605
|
}
|
package/lib/database/common.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const isModelSpace: (name: string) => boolean | "";
|
|
2
2
|
export declare const isPaperSpace: (name: string) => boolean | "";
|
|
3
|
+
export declare const idToString: (id: number | bigint) => string;
|
|
4
|
+
export declare const isValidPointer: (ptr: number | bigint) => boolean;
|
|
3
5
|
export interface DwgPoint2D {
|
|
4
6
|
x: number;
|
|
5
7
|
y: number;
|
package/lib/database/common.js
CHANGED
|
@@ -6,4 +6,15 @@ export const isModelSpace = (name) => {
|
|
|
6
6
|
export const isPaperSpace = (name) => {
|
|
7
7
|
return name && name.toUpperCase().startsWith(MODEL_SPACE_PREFIX);
|
|
8
8
|
};
|
|
9
|
+
export const idToString = (id) => {
|
|
10
|
+
return id.toString(16).toUpperCase();
|
|
11
|
+
};
|
|
12
|
+
export const isValidPointer = (ptr) => {
|
|
13
|
+
if (typeof ptr === 'bigint') {
|
|
14
|
+
return ptr !== 0n;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return ptr !== 0;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
9
20
|
//# sourceMappingURL=common.js.map
|
|
@@ -7,11 +7,11 @@ export interface DwgEntity {
|
|
|
7
7
|
/**
|
|
8
8
|
* Handle
|
|
9
9
|
*/
|
|
10
|
-
handle:
|
|
10
|
+
handle: string;
|
|
11
11
|
/**
|
|
12
12
|
* Soft-pointer ID/handle to owner BLOCK_RECORD object
|
|
13
13
|
*/
|
|
14
|
-
ownerBlockRecordSoftId:
|
|
14
|
+
ownerBlockRecordSoftId: string;
|
|
15
15
|
/**
|
|
16
16
|
* Absent or zero indicates entity is in model space. 1 indicates entity is in paper space (optional).
|
|
17
17
|
*/
|
package/package.json
CHANGED