@mlightcad/libredwg-web 0.7.13 → 0.7.15
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/dist/libredwg-web.js +73 -11
- package/dist/libredwg-web.umd.cjs +73 -11
- package/lib/converter/entityConverter.d.ts +2 -0
- package/lib/converter/entityConverter.js +65 -2
- package/lib/database/entities/arcAlignedText.d.ts +102 -0
- package/lib/database/entities/arcAlignedText.js +2 -0
- package/lib/database/entities/index.d.ts +2 -0
- package/lib/database/entities/index.js +2 -0
- package/lib/database/entities/trace.d.ts +34 -0
- package/lib/database/entities/trace.js +2 -0
- package/package.json +1 -1
- package/wasm/libredwg-web.d.ts +561 -548
- package/wasm/libredwg-web.js +15 -2
- package/wasm/libredwg-web.wasm +0 -0
package/dist/libredwg-web.js
CHANGED
|
@@ -1299,6 +1299,8 @@ class LibreEntityConverter {
|
|
|
1299
1299
|
return this.convert3dSolid(entity_tio, commonAttrs);
|
|
1300
1300
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ARC) {
|
|
1301
1301
|
return this.convertArc(entity_tio, commonAttrs);
|
|
1302
|
+
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ARCALIGNEDTEXT) {
|
|
1303
|
+
return this.convertArcAlignedText(entity_tio, commonAttrs);
|
|
1302
1304
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ATTDEF) {
|
|
1303
1305
|
return this.convertAttdef(entity_tio, commonAttrs);
|
|
1304
1306
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_CIRCLE) {
|
|
@@ -1355,6 +1357,8 @@ class LibreEntityConverter {
|
|
|
1355
1357
|
return this.convertShape(entity_tio, commonAttrs);
|
|
1356
1358
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_SOLID) {
|
|
1357
1359
|
return this.convertSolid(entity_tio, commonAttrs);
|
|
1360
|
+
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_TRACE) {
|
|
1361
|
+
return this.convertTrace(entity_tio, commonAttrs);
|
|
1358
1362
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_SPLINE) {
|
|
1359
1363
|
return this.convertSpline(entity_tio, commonAttrs);
|
|
1360
1364
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_TABLE) {
|
|
@@ -1448,6 +1452,54 @@ class LibreEntityConverter {
|
|
|
1448
1452
|
extrusionDirection
|
|
1449
1453
|
};
|
|
1450
1454
|
}
|
|
1455
|
+
convertArcAlignedText(entity, commonAttrs) {
|
|
1456
|
+
const libredwg = this.libredwg;
|
|
1457
|
+
const numberField = (field, fallback = 0) => {
|
|
1458
|
+
const value = libredwg.dwg_dynapi_entity_data(entity, field);
|
|
1459
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
1460
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
1461
|
+
const parsed = Number(value);
|
|
1462
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
1463
|
+
}
|
|
1464
|
+
return fallback;
|
|
1465
|
+
};
|
|
1466
|
+
const center = libredwg.dwg_dynapi_entity_data(entity, "center");
|
|
1467
|
+
const extrusion = libredwg.dwg_dynapi_entity_data(entity, "extrusion");
|
|
1468
|
+
const arcRef = libredwg.dwg_dynapi_entity_data(entity, "arc_handle");
|
|
1469
|
+
const xScale = numberField("xscale", 1);
|
|
1470
|
+
return {
|
|
1471
|
+
type: "ARCALIGNEDTEXT",
|
|
1472
|
+
...commonAttrs,
|
|
1473
|
+
text: libredwg.dwg_dynapi_entity_data(entity, "text_value") ?? "",
|
|
1474
|
+
textSize: numberField("text_size"),
|
|
1475
|
+
xScale: xScale > 0 ? xScale : 1,
|
|
1476
|
+
characterSpacing: numberField("char_spacing"),
|
|
1477
|
+
styleName: libredwg.dwg_dynapi_entity_data(entity, "style") ?? "",
|
|
1478
|
+
fontName: libredwg.dwg_dynapi_entity_data(entity, "font_name") ?? "",
|
|
1479
|
+
bigFontName: libredwg.dwg_dynapi_entity_data(entity, "bigfont_name") ?? "",
|
|
1480
|
+
offsetFromArc: numberField("offset_from_arc"),
|
|
1481
|
+
rightOffset: numberField("right_offset"),
|
|
1482
|
+
leftOffset: numberField("left_offset"),
|
|
1483
|
+
center: center ?? { x: 0, y: 0, z: 0 },
|
|
1484
|
+
radius: libredwg.dwg_dynapi_entity_data(entity, "radius") ?? 0,
|
|
1485
|
+
startAngle: libredwg.dwg_dynapi_entity_data(entity, "start_angle") ?? 0,
|
|
1486
|
+
endAngle: libredwg.dwg_dynapi_entity_data(entity, "end_angle") ?? 0,
|
|
1487
|
+
extrusionDirection: extrusion ?? { x: 0, y: 0, z: 1 },
|
|
1488
|
+
rawTextColor: libredwg.dwg_dynapi_entity_data(entity, "color") ?? 256,
|
|
1489
|
+
characterSet: libredwg.dwg_dynapi_entity_data(entity, "character_set") ?? 0,
|
|
1490
|
+
pitchAndFamily: libredwg.dwg_dynapi_entity_data(entity, "pitch_and_family") ?? 0,
|
|
1491
|
+
isShx: (libredwg.dwg_dynapi_entity_data(entity, "is_shx") ?? 0) !== 0,
|
|
1492
|
+
isBold: (libredwg.dwg_dynapi_entity_data(entity, "is_bold") ?? 0) !== 0,
|
|
1493
|
+
isItalic: (libredwg.dwg_dynapi_entity_data(entity, "is_italic") ?? 0) !== 0,
|
|
1494
|
+
isUnderlined: (libredwg.dwg_dynapi_entity_data(entity, "is_underlined") ?? 0) !== 0,
|
|
1495
|
+
alignment: libredwg.dwg_dynapi_entity_data(entity, "alignment") ?? 0,
|
|
1496
|
+
isReverse: (libredwg.dwg_dynapi_entity_data(entity, "is_reverse") ?? 0) !== 0,
|
|
1497
|
+
wizardFlag: libredwg.dwg_dynapi_entity_data(entity, "wizard_flag") ?? 0,
|
|
1498
|
+
textPosition: libredwg.dwg_dynapi_entity_data(entity, "text_position") ?? 1,
|
|
1499
|
+
textDirection: libredwg.dwg_dynapi_entity_data(entity, "text_direction") ?? 1,
|
|
1500
|
+
arcHandle: arcRef ? libredwg.dwg_ref_get_id(arcRef) ?? "" : ""
|
|
1501
|
+
};
|
|
1502
|
+
}
|
|
1451
1503
|
convertEmbeddedMText(entity, subclassName) {
|
|
1452
1504
|
const libredwg = this.libredwg;
|
|
1453
1505
|
const attachmentPoint = libredwg.dwg_dynapi_subclass_data(entity, subclassName, "attachment");
|
|
@@ -2938,6 +2990,13 @@ class LibreEntityConverter {
|
|
|
2938
2990
|
extrusionDirection
|
|
2939
2991
|
};
|
|
2940
2992
|
}
|
|
2993
|
+
convertTrace(entity, commonAttrs) {
|
|
2994
|
+
const solid = this.convertSolid(entity, commonAttrs);
|
|
2995
|
+
return {
|
|
2996
|
+
...solid,
|
|
2997
|
+
type: "TRACE"
|
|
2998
|
+
};
|
|
2999
|
+
}
|
|
2941
3000
|
convertSpline(entity, commonAttrs) {
|
|
2942
3001
|
const libredwg = this.libredwg;
|
|
2943
3002
|
const flag = libredwg.dwg_dynapi_entity_data(entity, "splineflags");
|
|
@@ -2998,23 +3057,26 @@ class LibreEntityConverter {
|
|
|
2998
3057
|
const rowCount = libredwg.dwg_dynapi_entity_data(entity, "num_rows");
|
|
2999
3058
|
const columnCount = libredwg.dwg_dynapi_entity_data(entity, "num_cols");
|
|
3000
3059
|
const row_heights_ptr = libredwg.dwg_dynapi_entity_data(entity, "row_heights");
|
|
3001
|
-
const rowHeightArr = libredwg.dwg_ptr_to_double_array(
|
|
3002
|
-
row_heights_ptr,
|
|
3003
|
-
rowCount
|
|
3004
|
-
);
|
|
3060
|
+
const rowHeightArr = libredwg.dwg_ptr_to_double_array(row_heights_ptr, rowCount);
|
|
3005
3061
|
const col_widths_ptr = libredwg.dwg_dynapi_entity_data(entity, "col_widths");
|
|
3006
|
-
const columnWidthArr = libredwg.dwg_ptr_to_double_array(
|
|
3007
|
-
col_widths_ptr,
|
|
3008
|
-
columnCount
|
|
3009
|
-
);
|
|
3062
|
+
const columnWidthArr = libredwg.dwg_ptr_to_double_array(col_widths_ptr, columnCount);
|
|
3010
3063
|
const table_style_ref = libredwg.dwg_dynapi_entity_data(entity, "tablestyle");
|
|
3011
3064
|
const tableStyleId = libredwg.dwg_ref_get_id(table_style_ref) ?? "";
|
|
3012
3065
|
const block_header_ref = libredwg.dwg_dynapi_entity_data(entity, "block_header");
|
|
3013
3066
|
const blockRecordHandle = libredwg.dwg_ref_get_id(block_header_ref) ?? "";
|
|
3014
3067
|
const overrideFlag = libredwg.dwg_dynapi_entity_data(entity, "table_flag_override");
|
|
3015
|
-
const borderColorOverrideFlag = libredwg.dwg_dynapi_entity_data(
|
|
3016
|
-
|
|
3017
|
-
|
|
3068
|
+
const borderColorOverrideFlag = libredwg.dwg_dynapi_entity_data(
|
|
3069
|
+
entity,
|
|
3070
|
+
"border_color_overrides_flag"
|
|
3071
|
+
);
|
|
3072
|
+
const borderLineWeightOverrideFlag = libredwg.dwg_dynapi_entity_data(
|
|
3073
|
+
entity,
|
|
3074
|
+
"border_lineweight_overrides_flag"
|
|
3075
|
+
);
|
|
3076
|
+
const borderVisibilityOverrideFlag = libredwg.dwg_dynapi_entity_data(
|
|
3077
|
+
entity,
|
|
3078
|
+
"border_visibility_overrides_flag"
|
|
3079
|
+
);
|
|
3018
3080
|
const num_cells = libredwg.dwg_dynapi_entity_data(entity, "num_cells");
|
|
3019
3081
|
const cells_ptr = libredwg.dwg_dynapi_entity_data(entity, "cells");
|
|
3020
3082
|
const cells = libredwg.dwg_ptr_to_table_cell_array(cells_ptr, num_cells);
|
|
@@ -1301,6 +1301,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1301
1301
|
return this.convert3dSolid(entity_tio, commonAttrs);
|
|
1302
1302
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ARC) {
|
|
1303
1303
|
return this.convertArc(entity_tio, commonAttrs);
|
|
1304
|
+
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ARCALIGNEDTEXT) {
|
|
1305
|
+
return this.convertArcAlignedText(entity_tio, commonAttrs);
|
|
1304
1306
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ATTDEF) {
|
|
1305
1307
|
return this.convertAttdef(entity_tio, commonAttrs);
|
|
1306
1308
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_CIRCLE) {
|
|
@@ -1357,6 +1359,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1357
1359
|
return this.convertShape(entity_tio, commonAttrs);
|
|
1358
1360
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_SOLID) {
|
|
1359
1361
|
return this.convertSolid(entity_tio, commonAttrs);
|
|
1362
|
+
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_TRACE) {
|
|
1363
|
+
return this.convertTrace(entity_tio, commonAttrs);
|
|
1360
1364
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_SPLINE) {
|
|
1361
1365
|
return this.convertSpline(entity_tio, commonAttrs);
|
|
1362
1366
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_TABLE) {
|
|
@@ -1450,6 +1454,54 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1450
1454
|
extrusionDirection
|
|
1451
1455
|
};
|
|
1452
1456
|
}
|
|
1457
|
+
convertArcAlignedText(entity, commonAttrs) {
|
|
1458
|
+
const libredwg = this.libredwg;
|
|
1459
|
+
const numberField = (field, fallback = 0) => {
|
|
1460
|
+
const value = libredwg.dwg_dynapi_entity_data(entity, field);
|
|
1461
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
1462
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
1463
|
+
const parsed = Number(value);
|
|
1464
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
1465
|
+
}
|
|
1466
|
+
return fallback;
|
|
1467
|
+
};
|
|
1468
|
+
const center = libredwg.dwg_dynapi_entity_data(entity, "center");
|
|
1469
|
+
const extrusion = libredwg.dwg_dynapi_entity_data(entity, "extrusion");
|
|
1470
|
+
const arcRef = libredwg.dwg_dynapi_entity_data(entity, "arc_handle");
|
|
1471
|
+
const xScale = numberField("xscale", 1);
|
|
1472
|
+
return {
|
|
1473
|
+
type: "ARCALIGNEDTEXT",
|
|
1474
|
+
...commonAttrs,
|
|
1475
|
+
text: libredwg.dwg_dynapi_entity_data(entity, "text_value") ?? "",
|
|
1476
|
+
textSize: numberField("text_size"),
|
|
1477
|
+
xScale: xScale > 0 ? xScale : 1,
|
|
1478
|
+
characterSpacing: numberField("char_spacing"),
|
|
1479
|
+
styleName: libredwg.dwg_dynapi_entity_data(entity, "style") ?? "",
|
|
1480
|
+
fontName: libredwg.dwg_dynapi_entity_data(entity, "font_name") ?? "",
|
|
1481
|
+
bigFontName: libredwg.dwg_dynapi_entity_data(entity, "bigfont_name") ?? "",
|
|
1482
|
+
offsetFromArc: numberField("offset_from_arc"),
|
|
1483
|
+
rightOffset: numberField("right_offset"),
|
|
1484
|
+
leftOffset: numberField("left_offset"),
|
|
1485
|
+
center: center ?? { x: 0, y: 0, z: 0 },
|
|
1486
|
+
radius: libredwg.dwg_dynapi_entity_data(entity, "radius") ?? 0,
|
|
1487
|
+
startAngle: libredwg.dwg_dynapi_entity_data(entity, "start_angle") ?? 0,
|
|
1488
|
+
endAngle: libredwg.dwg_dynapi_entity_data(entity, "end_angle") ?? 0,
|
|
1489
|
+
extrusionDirection: extrusion ?? { x: 0, y: 0, z: 1 },
|
|
1490
|
+
rawTextColor: libredwg.dwg_dynapi_entity_data(entity, "color") ?? 256,
|
|
1491
|
+
characterSet: libredwg.dwg_dynapi_entity_data(entity, "character_set") ?? 0,
|
|
1492
|
+
pitchAndFamily: libredwg.dwg_dynapi_entity_data(entity, "pitch_and_family") ?? 0,
|
|
1493
|
+
isShx: (libredwg.dwg_dynapi_entity_data(entity, "is_shx") ?? 0) !== 0,
|
|
1494
|
+
isBold: (libredwg.dwg_dynapi_entity_data(entity, "is_bold") ?? 0) !== 0,
|
|
1495
|
+
isItalic: (libredwg.dwg_dynapi_entity_data(entity, "is_italic") ?? 0) !== 0,
|
|
1496
|
+
isUnderlined: (libredwg.dwg_dynapi_entity_data(entity, "is_underlined") ?? 0) !== 0,
|
|
1497
|
+
alignment: libredwg.dwg_dynapi_entity_data(entity, "alignment") ?? 0,
|
|
1498
|
+
isReverse: (libredwg.dwg_dynapi_entity_data(entity, "is_reverse") ?? 0) !== 0,
|
|
1499
|
+
wizardFlag: libredwg.dwg_dynapi_entity_data(entity, "wizard_flag") ?? 0,
|
|
1500
|
+
textPosition: libredwg.dwg_dynapi_entity_data(entity, "text_position") ?? 1,
|
|
1501
|
+
textDirection: libredwg.dwg_dynapi_entity_data(entity, "text_direction") ?? 1,
|
|
1502
|
+
arcHandle: arcRef ? libredwg.dwg_ref_get_id(arcRef) ?? "" : ""
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1453
1505
|
convertEmbeddedMText(entity, subclassName) {
|
|
1454
1506
|
const libredwg = this.libredwg;
|
|
1455
1507
|
const attachmentPoint = libredwg.dwg_dynapi_subclass_data(entity, subclassName, "attachment");
|
|
@@ -2940,6 +2992,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2940
2992
|
extrusionDirection
|
|
2941
2993
|
};
|
|
2942
2994
|
}
|
|
2995
|
+
convertTrace(entity, commonAttrs) {
|
|
2996
|
+
const solid = this.convertSolid(entity, commonAttrs);
|
|
2997
|
+
return {
|
|
2998
|
+
...solid,
|
|
2999
|
+
type: "TRACE"
|
|
3000
|
+
};
|
|
3001
|
+
}
|
|
2943
3002
|
convertSpline(entity, commonAttrs) {
|
|
2944
3003
|
const libredwg = this.libredwg;
|
|
2945
3004
|
const flag = libredwg.dwg_dynapi_entity_data(entity, "splineflags");
|
|
@@ -3000,23 +3059,26 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3000
3059
|
const rowCount = libredwg.dwg_dynapi_entity_data(entity, "num_rows");
|
|
3001
3060
|
const columnCount = libredwg.dwg_dynapi_entity_data(entity, "num_cols");
|
|
3002
3061
|
const row_heights_ptr = libredwg.dwg_dynapi_entity_data(entity, "row_heights");
|
|
3003
|
-
const rowHeightArr = libredwg.dwg_ptr_to_double_array(
|
|
3004
|
-
row_heights_ptr,
|
|
3005
|
-
rowCount
|
|
3006
|
-
);
|
|
3062
|
+
const rowHeightArr = libredwg.dwg_ptr_to_double_array(row_heights_ptr, rowCount);
|
|
3007
3063
|
const col_widths_ptr = libredwg.dwg_dynapi_entity_data(entity, "col_widths");
|
|
3008
|
-
const columnWidthArr = libredwg.dwg_ptr_to_double_array(
|
|
3009
|
-
col_widths_ptr,
|
|
3010
|
-
columnCount
|
|
3011
|
-
);
|
|
3064
|
+
const columnWidthArr = libredwg.dwg_ptr_to_double_array(col_widths_ptr, columnCount);
|
|
3012
3065
|
const table_style_ref = libredwg.dwg_dynapi_entity_data(entity, "tablestyle");
|
|
3013
3066
|
const tableStyleId = libredwg.dwg_ref_get_id(table_style_ref) ?? "";
|
|
3014
3067
|
const block_header_ref = libredwg.dwg_dynapi_entity_data(entity, "block_header");
|
|
3015
3068
|
const blockRecordHandle = libredwg.dwg_ref_get_id(block_header_ref) ?? "";
|
|
3016
3069
|
const overrideFlag = libredwg.dwg_dynapi_entity_data(entity, "table_flag_override");
|
|
3017
|
-
const borderColorOverrideFlag = libredwg.dwg_dynapi_entity_data(
|
|
3018
|
-
|
|
3019
|
-
|
|
3070
|
+
const borderColorOverrideFlag = libredwg.dwg_dynapi_entity_data(
|
|
3071
|
+
entity,
|
|
3072
|
+
"border_color_overrides_flag"
|
|
3073
|
+
);
|
|
3074
|
+
const borderLineWeightOverrideFlag = libredwg.dwg_dynapi_entity_data(
|
|
3075
|
+
entity,
|
|
3076
|
+
"border_lineweight_overrides_flag"
|
|
3077
|
+
);
|
|
3078
|
+
const borderVisibilityOverrideFlag = libredwg.dwg_dynapi_entity_data(
|
|
3079
|
+
entity,
|
|
3080
|
+
"border_visibility_overrides_flag"
|
|
3081
|
+
);
|
|
3020
3082
|
const num_cells = libredwg.dwg_dynapi_entity_data(entity, "num_cells");
|
|
3021
3083
|
const cells_ptr = libredwg.dwg_dynapi_entity_data(entity, "cells");
|
|
3022
3084
|
const cells = libredwg.dwg_ptr_to_table_cell_array(cells_ptr, num_cells);
|
|
@@ -15,6 +15,7 @@ export declare class LibreEntityConverter {
|
|
|
15
15
|
private convert3dFace;
|
|
16
16
|
private convert3dSolid;
|
|
17
17
|
private convertArc;
|
|
18
|
+
private convertArcAlignedText;
|
|
18
19
|
private convertEmbeddedMText;
|
|
19
20
|
private convertAttdef;
|
|
20
21
|
private convertAttrib;
|
|
@@ -47,6 +48,7 @@ export declare class LibreEntityConverter {
|
|
|
47
48
|
private convertSection;
|
|
48
49
|
private convertShape;
|
|
49
50
|
private convertSolid;
|
|
51
|
+
private convertTrace;
|
|
50
52
|
private convertSpline;
|
|
51
53
|
private convertTable;
|
|
52
54
|
private convertTableCells;
|
|
@@ -55,6 +55,9 @@ export class LibreEntityConverter {
|
|
|
55
55
|
else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ARC) {
|
|
56
56
|
return this.convertArc(entity_tio, commonAttrs);
|
|
57
57
|
}
|
|
58
|
+
else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ARCALIGNEDTEXT) {
|
|
59
|
+
return this.convertArcAlignedText(entity_tio, commonAttrs);
|
|
60
|
+
}
|
|
58
61
|
else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ATTDEF) {
|
|
59
62
|
return this.convertAttdef(entity_tio, commonAttrs);
|
|
60
63
|
// libredwg stores ATTRIB as children of one INSERT entity.
|
|
@@ -144,6 +147,9 @@ export class LibreEntityConverter {
|
|
|
144
147
|
else if (fixedtype == Dwg_Object_Type.DWG_TYPE_SOLID) {
|
|
145
148
|
return this.convertSolid(entity_tio, commonAttrs);
|
|
146
149
|
}
|
|
150
|
+
else if (fixedtype == Dwg_Object_Type.DWG_TYPE_TRACE) {
|
|
151
|
+
return this.convertTrace(entity_tio, commonAttrs);
|
|
152
|
+
}
|
|
147
153
|
else if (fixedtype == Dwg_Object_Type.DWG_TYPE_SPLINE) {
|
|
148
154
|
return this.convertSpline(entity_tio, commonAttrs);
|
|
149
155
|
}
|
|
@@ -241,6 +247,56 @@ export class LibreEntityConverter {
|
|
|
241
247
|
extrusionDirection: extrusionDirection
|
|
242
248
|
};
|
|
243
249
|
}
|
|
250
|
+
convertArcAlignedText(entity, commonAttrs) {
|
|
251
|
+
const libredwg = this.libredwg;
|
|
252
|
+
const numberField = (field, fallback = 0) => {
|
|
253
|
+
const value = libredwg.dwg_dynapi_entity_data(entity, field);
|
|
254
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
255
|
+
return value;
|
|
256
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
257
|
+
const parsed = Number(value);
|
|
258
|
+
if (Number.isFinite(parsed))
|
|
259
|
+
return parsed;
|
|
260
|
+
}
|
|
261
|
+
return fallback;
|
|
262
|
+
};
|
|
263
|
+
const center = libredwg.dwg_dynapi_entity_data(entity, 'center');
|
|
264
|
+
const extrusion = libredwg.dwg_dynapi_entity_data(entity, 'extrusion');
|
|
265
|
+
const arcRef = libredwg.dwg_dynapi_entity_data(entity, 'arc_handle');
|
|
266
|
+
const xScale = numberField('xscale', 1);
|
|
267
|
+
return {
|
|
268
|
+
type: 'ARCALIGNEDTEXT',
|
|
269
|
+
...commonAttrs,
|
|
270
|
+
text: libredwg.dwg_dynapi_entity_data(entity, 'text_value') ?? '',
|
|
271
|
+
textSize: numberField('text_size'),
|
|
272
|
+
xScale: xScale > 0 ? xScale : 1,
|
|
273
|
+
characterSpacing: numberField('char_spacing'),
|
|
274
|
+
styleName: libredwg.dwg_dynapi_entity_data(entity, 'style') ?? '',
|
|
275
|
+
fontName: libredwg.dwg_dynapi_entity_data(entity, 'font_name') ?? '',
|
|
276
|
+
bigFontName: libredwg.dwg_dynapi_entity_data(entity, 'bigfont_name') ?? '',
|
|
277
|
+
offsetFromArc: numberField('offset_from_arc'),
|
|
278
|
+
rightOffset: numberField('right_offset'),
|
|
279
|
+
leftOffset: numberField('left_offset'),
|
|
280
|
+
center: center ?? { x: 0, y: 0, z: 0 },
|
|
281
|
+
radius: libredwg.dwg_dynapi_entity_data(entity, 'radius') ?? 0,
|
|
282
|
+
startAngle: libredwg.dwg_dynapi_entity_data(entity, 'start_angle') ?? 0,
|
|
283
|
+
endAngle: libredwg.dwg_dynapi_entity_data(entity, 'end_angle') ?? 0,
|
|
284
|
+
extrusionDirection: extrusion ?? { x: 0, y: 0, z: 1 },
|
|
285
|
+
rawTextColor: libredwg.dwg_dynapi_entity_data(entity, 'color') ?? 256,
|
|
286
|
+
characterSet: libredwg.dwg_dynapi_entity_data(entity, 'character_set') ?? 0,
|
|
287
|
+
pitchAndFamily: libredwg.dwg_dynapi_entity_data(entity, 'pitch_and_family') ?? 0,
|
|
288
|
+
isShx: (libredwg.dwg_dynapi_entity_data(entity, 'is_shx') ?? 0) !== 0,
|
|
289
|
+
isBold: (libredwg.dwg_dynapi_entity_data(entity, 'is_bold') ?? 0) !== 0,
|
|
290
|
+
isItalic: (libredwg.dwg_dynapi_entity_data(entity, 'is_italic') ?? 0) !== 0,
|
|
291
|
+
isUnderlined: (libredwg.dwg_dynapi_entity_data(entity, 'is_underlined') ?? 0) !== 0,
|
|
292
|
+
alignment: libredwg.dwg_dynapi_entity_data(entity, 'alignment') ?? 0,
|
|
293
|
+
isReverse: (libredwg.dwg_dynapi_entity_data(entity, 'is_reverse') ?? 0) !== 0,
|
|
294
|
+
wizardFlag: libredwg.dwg_dynapi_entity_data(entity, 'wizard_flag') ?? 0,
|
|
295
|
+
textPosition: libredwg.dwg_dynapi_entity_data(entity, 'text_position') ?? 1,
|
|
296
|
+
textDirection: libredwg.dwg_dynapi_entity_data(entity, 'text_direction') ?? 1,
|
|
297
|
+
arcHandle: arcRef ? (libredwg.dwg_ref_get_id(arcRef) ?? '') : ''
|
|
298
|
+
};
|
|
299
|
+
}
|
|
244
300
|
convertEmbeddedMText(entity, subclassName) {
|
|
245
301
|
const libredwg = this.libredwg;
|
|
246
302
|
const attachmentPoint = libredwg.dwg_dynapi_subclass_data(entity, subclassName, 'attachment');
|
|
@@ -1554,6 +1610,13 @@ export class LibreEntityConverter {
|
|
|
1554
1610
|
extrusionDirection: extrusionDirection
|
|
1555
1611
|
};
|
|
1556
1612
|
}
|
|
1613
|
+
convertTrace(entity, commonAttrs) {
|
|
1614
|
+
const solid = this.convertSolid(entity, commonAttrs);
|
|
1615
|
+
return {
|
|
1616
|
+
...solid,
|
|
1617
|
+
type: 'TRACE'
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1557
1620
|
convertSpline(entity, commonAttrs) {
|
|
1558
1621
|
const libredwg = this.libredwg;
|
|
1559
1622
|
const flag = libredwg.dwg_dynapi_entity_data(entity, 'splineflags');
|
|
@@ -1615,9 +1678,9 @@ export class LibreEntityConverter {
|
|
|
1615
1678
|
const col_widths_ptr = libredwg.dwg_dynapi_entity_data(entity, 'col_widths');
|
|
1616
1679
|
const columnWidthArr = libredwg.dwg_ptr_to_double_array(col_widths_ptr, columnCount);
|
|
1617
1680
|
const table_style_ref = libredwg.dwg_dynapi_entity_data(entity, 'tablestyle');
|
|
1618
|
-
const tableStyleId =
|
|
1681
|
+
const tableStyleId = libredwg.dwg_ref_get_id(table_style_ref) ?? '';
|
|
1619
1682
|
const block_header_ref = libredwg.dwg_dynapi_entity_data(entity, 'block_header');
|
|
1620
|
-
const blockRecordHandle =
|
|
1683
|
+
const blockRecordHandle = libredwg.dwg_ref_get_id(block_header_ref) ?? '';
|
|
1621
1684
|
const overrideFlag = libredwg.dwg_dynapi_entity_data(entity, 'table_flag_override');
|
|
1622
1685
|
const borderColorOverrideFlag = libredwg.dwg_dynapi_entity_data(entity, 'border_color_overrides_flag');
|
|
1623
1686
|
const borderLineWeightOverrideFlag = libredwg.dwg_dynapi_entity_data(entity, 'border_lineweight_overrides_flag');
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { DwgPoint3D } from '../common';
|
|
2
|
+
import { DwgEntity } from './entity';
|
|
3
|
+
/**
|
|
4
|
+
* Express Tools arc-aligned text (DXF ARCALIGNEDTEXT / AcDbArcAlignedText).
|
|
5
|
+
* Doubles that the DWG stores as strings (text size, scales, offsets) are
|
|
6
|
+
* already parsed to numbers here.
|
|
7
|
+
*/
|
|
8
|
+
export interface DwgArcAlignedTextEntity extends DwgEntity {
|
|
9
|
+
/**
|
|
10
|
+
* Entity type
|
|
11
|
+
*/
|
|
12
|
+
type: 'ARCALIGNEDTEXT';
|
|
13
|
+
/**
|
|
14
|
+
* Text contents
|
|
15
|
+
*/
|
|
16
|
+
text: string;
|
|
17
|
+
/**
|
|
18
|
+
* Text height
|
|
19
|
+
*/
|
|
20
|
+
textSize: number;
|
|
21
|
+
/**
|
|
22
|
+
* Width factor
|
|
23
|
+
*/
|
|
24
|
+
xScale: number;
|
|
25
|
+
/**
|
|
26
|
+
* Extra spacing between characters, in text-height units
|
|
27
|
+
*/
|
|
28
|
+
characterSpacing: number;
|
|
29
|
+
/**
|
|
30
|
+
* Text style name
|
|
31
|
+
*/
|
|
32
|
+
styleName: string;
|
|
33
|
+
/**
|
|
34
|
+
* Font file name
|
|
35
|
+
*/
|
|
36
|
+
fontName: string;
|
|
37
|
+
/**
|
|
38
|
+
* Bigfont file name
|
|
39
|
+
*/
|
|
40
|
+
bigFontName: string;
|
|
41
|
+
/**
|
|
42
|
+
* Offset from the reference arc
|
|
43
|
+
*/
|
|
44
|
+
offsetFromArc: number;
|
|
45
|
+
/**
|
|
46
|
+
* Offset from the end of the arc
|
|
47
|
+
*/
|
|
48
|
+
rightOffset: number;
|
|
49
|
+
/**
|
|
50
|
+
* Offset from the start of the arc
|
|
51
|
+
*/
|
|
52
|
+
leftOffset: number;
|
|
53
|
+
/**
|
|
54
|
+
* Center of the reference arc (in OCS)
|
|
55
|
+
*/
|
|
56
|
+
center: DwgPoint3D;
|
|
57
|
+
/**
|
|
58
|
+
* Radius of the reference arc
|
|
59
|
+
*/
|
|
60
|
+
radius: number;
|
|
61
|
+
/**
|
|
62
|
+
* Start angle of the reference arc
|
|
63
|
+
*/
|
|
64
|
+
startAngle: number;
|
|
65
|
+
/**
|
|
66
|
+
* End angle of the reference arc
|
|
67
|
+
*/
|
|
68
|
+
endAngle: number;
|
|
69
|
+
/**
|
|
70
|
+
* Extrusion direction (optional; default = 0, 0, 1)
|
|
71
|
+
*/
|
|
72
|
+
extrusionDirection: DwgPoint3D;
|
|
73
|
+
/**
|
|
74
|
+
* Raw text color: 0 ByBlock, 256 ByLayer, 1-255 ACI, or a true-color method
|
|
75
|
+
*/
|
|
76
|
+
rawTextColor: number;
|
|
77
|
+
characterSet: number;
|
|
78
|
+
pitchAndFamily: number;
|
|
79
|
+
isShx: boolean;
|
|
80
|
+
isBold: boolean;
|
|
81
|
+
isItalic: boolean;
|
|
82
|
+
isUnderlined: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* 1 Fit, 2 Left, 3 Right, 4 Center
|
|
85
|
+
*/
|
|
86
|
+
alignment: number;
|
|
87
|
+
isReverse: boolean;
|
|
88
|
+
wizardFlag: number;
|
|
89
|
+
/**
|
|
90
|
+
* 1 OnConvexSide, 2 OnConcaveSide
|
|
91
|
+
*/
|
|
92
|
+
textPosition: number;
|
|
93
|
+
/**
|
|
94
|
+
* 1 OutwardFromCenter, 2 InwardToTheCenter
|
|
95
|
+
*/
|
|
96
|
+
textDirection: number;
|
|
97
|
+
/**
|
|
98
|
+
* Handle of the associated ARC, if any
|
|
99
|
+
*/
|
|
100
|
+
arcHandle: string;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=arcAlignedText.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './3dface';
|
|
2
2
|
export * from './arc';
|
|
3
|
+
export * from './arcAlignedText';
|
|
3
4
|
export * from './attdef';
|
|
4
5
|
export * from './attrib';
|
|
5
6
|
export * from './circle';
|
|
@@ -29,6 +30,7 @@ export * from './spline';
|
|
|
29
30
|
export * from './table';
|
|
30
31
|
export * from './text';
|
|
31
32
|
export * from './tolerance';
|
|
33
|
+
export * from './trace';
|
|
32
34
|
export * from './vertex';
|
|
33
35
|
export * from './viewport';
|
|
34
36
|
export * from './wipeout';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './3dface';
|
|
2
2
|
export * from './arc';
|
|
3
|
+
export * from './arcAlignedText';
|
|
3
4
|
export * from './attdef';
|
|
4
5
|
export * from './attrib';
|
|
5
6
|
export * from './circle';
|
|
@@ -29,6 +30,7 @@ export * from './spline';
|
|
|
29
30
|
export * from './table';
|
|
30
31
|
export * from './text';
|
|
31
32
|
export * from './tolerance';
|
|
33
|
+
export * from './trace';
|
|
32
34
|
export * from './vertex';
|
|
33
35
|
export * from './viewport';
|
|
34
36
|
export * from './wipeout';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DwgPoint2D, DwgPoint3D } from '../common';
|
|
2
|
+
import { DwgEntity } from './entity';
|
|
3
|
+
export interface DwgTraceEntity extends DwgEntity {
|
|
4
|
+
/**
|
|
5
|
+
* Entity type
|
|
6
|
+
*/
|
|
7
|
+
type: 'TRACE';
|
|
8
|
+
/**
|
|
9
|
+
* Corner1
|
|
10
|
+
*/
|
|
11
|
+
corner1: DwgPoint2D;
|
|
12
|
+
/**
|
|
13
|
+
* Corner2
|
|
14
|
+
*/
|
|
15
|
+
corner2: DwgPoint2D;
|
|
16
|
+
/**
|
|
17
|
+
* Corner3
|
|
18
|
+
*/
|
|
19
|
+
corner3: DwgPoint2D;
|
|
20
|
+
/**
|
|
21
|
+
* Corner4. If only three corners are entered to define the TRACE,
|
|
22
|
+
* then the fourth corner coordinate is the same as the third.
|
|
23
|
+
*/
|
|
24
|
+
corner4?: DwgPoint2D;
|
|
25
|
+
/**
|
|
26
|
+
* Thickness (optional; default = 0)
|
|
27
|
+
*/
|
|
28
|
+
thickness: number;
|
|
29
|
+
/**
|
|
30
|
+
* Extrusion direction (optional; default = 0, 0, 1)
|
|
31
|
+
*/
|
|
32
|
+
extrusionDirection: DwgPoint3D;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=trace.d.ts.map
|
package/package.json
CHANGED