@mlightcad/libredwg-web 0.7.11 → 0.7.13

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.
@@ -1997,13 +1997,21 @@ class LibreEntityConverter {
1997
1997
  const num_bulges = libredwg.dwg_dynapi_entity_data(entity, "num_bulges");
1998
1998
  const bulges_ptr = libredwg.dwg_dynapi_entity_data(entity, "bulges");
1999
1999
  const bulges = libredwg.dwg_ptr_to_double_array(bulges_ptr, num_bulges);
2000
+ const num_widths = libredwg.dwg_dynapi_entity_data(entity, "num_widths") ?? 0;
2001
+ const widths_ptr = libredwg.dwg_dynapi_entity_data(entity, "widths");
2002
+ const widthDoubles = num_widths > 0 && widths_ptr ? libredwg.dwg_ptr_to_double_array(widths_ptr, num_widths * 2) : [];
2000
2003
  points.forEach((point, index) => {
2001
- vertices.push({
2004
+ const vertex = {
2002
2005
  id: index,
2003
2006
  x: point.x,
2004
2007
  y: point.y,
2005
2008
  bulge: bulges.length > index ? bulges[index] : 0
2006
- });
2009
+ };
2010
+ if (index < num_widths && widthDoubles.length >= (index + 1) * 2) {
2011
+ vertex.startWidth = widthDoubles[index * 2];
2012
+ vertex.endWidth = widthDoubles[index * 2 + 1];
2013
+ }
2014
+ vertices.push(vertex);
2007
2015
  });
2008
2016
  return {
2009
2017
  type: "LWPOLYLINE",
@@ -3993,8 +4001,10 @@ class LibreDwgConverter {
3993
4001
  dashes.forEach((dash) => {
3994
4002
  patterns.push({
3995
4003
  elementLength: dash.length || 0,
3996
- elementTypeFlag: dash.complex_shapecode,
3997
- shapeNumber: dash.shape_flag,
4004
+ // DXF 74: 1=absolute rotation, 2=text, 4=shape
4005
+ elementTypeFlag: dash.shape_flag || 0,
4006
+ // DXF 75: shape number (when flag has bit 4)
4007
+ shapeNumber: dash.complex_shapecode,
3998
4008
  // TODO: convert style handle to style object id
3999
4009
  // styleObjectId: dash.style,
4000
4010
  scale: dash.scale,
@@ -1999,13 +1999,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1999
1999
  const num_bulges = libredwg.dwg_dynapi_entity_data(entity, "num_bulges");
2000
2000
  const bulges_ptr = libredwg.dwg_dynapi_entity_data(entity, "bulges");
2001
2001
  const bulges = libredwg.dwg_ptr_to_double_array(bulges_ptr, num_bulges);
2002
+ const num_widths = libredwg.dwg_dynapi_entity_data(entity, "num_widths") ?? 0;
2003
+ const widths_ptr = libredwg.dwg_dynapi_entity_data(entity, "widths");
2004
+ const widthDoubles = num_widths > 0 && widths_ptr ? libredwg.dwg_ptr_to_double_array(widths_ptr, num_widths * 2) : [];
2002
2005
  points.forEach((point, index) => {
2003
- vertices.push({
2006
+ const vertex = {
2004
2007
  id: index,
2005
2008
  x: point.x,
2006
2009
  y: point.y,
2007
2010
  bulge: bulges.length > index ? bulges[index] : 0
2008
- });
2011
+ };
2012
+ if (index < num_widths && widthDoubles.length >= (index + 1) * 2) {
2013
+ vertex.startWidth = widthDoubles[index * 2];
2014
+ vertex.endWidth = widthDoubles[index * 2 + 1];
2015
+ }
2016
+ vertices.push(vertex);
2009
2017
  });
2010
2018
  return {
2011
2019
  type: "LWPOLYLINE",
@@ -3995,8 +4003,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3995
4003
  dashes.forEach((dash) => {
3996
4004
  patterns.push({
3997
4005
  elementLength: dash.length || 0,
3998
- elementTypeFlag: dash.complex_shapecode,
3999
- shapeNumber: dash.shape_flag,
4006
+ // DXF 74: 1=absolute rotation, 2=text, 4=shape
4007
+ elementTypeFlag: dash.shape_flag || 0,
4008
+ // DXF 75: shape number (when flag has bit 4)
4009
+ shapeNumber: dash.complex_shapecode,
4000
4010
  // TODO: convert style handle to style object id
4001
4011
  // styleObjectId: dash.style,
4002
4012
  scale: dash.scale,
@@ -703,8 +703,10 @@ export class LibreDwgConverter {
703
703
  dashes.forEach(dash => {
704
704
  patterns.push({
705
705
  elementLength: dash.length || 0,
706
- elementTypeFlag: dash.complex_shapecode,
707
- shapeNumber: dash.shape_flag,
706
+ // DXF 74: 1=absolute rotation, 2=text, 4=shape
707
+ elementTypeFlag: dash.shape_flag || 0,
708
+ // DXF 75: shape number (when flag has bit 4)
709
+ shapeNumber: dash.complex_shapecode,
708
710
  // TODO: convert style handle to style object id
709
711
  // styleObjectId: dash.style,
710
712
  scale: dash.scale,
@@ -835,13 +835,26 @@ export class LibreEntityConverter {
835
835
  const num_bulges = libredwg.dwg_dynapi_entity_data(entity, 'num_bulges');
836
836
  const bulges_ptr = libredwg.dwg_dynapi_entity_data(entity, 'bulges');
837
837
  const bulges = libredwg.dwg_ptr_to_double_array(bulges_ptr, num_bulges);
838
+ // Flag bit 32 = HAS_NUM_WIDTHS. Each Dwg_LWPOLYLINE_width is two BITCODE_BD
839
+ // values (start, end). Without copying these, tapered polylines (e.g. valve
840
+ // triangles) become zero-width lines after conversion.
841
+ const num_widths = libredwg.dwg_dynapi_entity_data(entity, 'num_widths') ?? 0;
842
+ const widths_ptr = libredwg.dwg_dynapi_entity_data(entity, 'widths');
843
+ const widthDoubles = num_widths > 0 && widths_ptr
844
+ ? libredwg.dwg_ptr_to_double_array(widths_ptr, num_widths * 2)
845
+ : [];
838
846
  points.forEach((point, index) => {
839
- vertices.push({
847
+ const vertex = {
840
848
  id: index,
841
849
  x: point.x,
842
850
  y: point.y,
843
851
  bulge: bulges.length > index ? bulges[index] : 0
844
- });
852
+ };
853
+ if (index < num_widths && widthDoubles.length >= (index + 1) * 2) {
854
+ vertex.startWidth = widthDoubles[index * 2];
855
+ vertex.endWidth = widthDoubles[index * 2 + 1];
856
+ }
857
+ vertices.push(vertex);
845
858
  });
846
859
  return {
847
860
  type: 'LWPOLYLINE',
@@ -9,13 +9,16 @@ export interface DwgLTypeTableEntry extends DwgCommonTableEntry {
9
9
  }
10
10
  export interface DwgLineTypeElement {
11
11
  elementLength: number;
12
+ /** DXF 74: 1 = absolute rotation, 2 = embedded text, 4 = shape */
12
13
  elementTypeFlag: number;
14
+ /** DXF 75: shape number when elementTypeFlag has bit 4 */
13
15
  shapeNumber?: number;
14
16
  styleObjectId?: string;
15
17
  scale?: number;
16
18
  rotation?: number;
17
19
  offsetX?: number;
18
20
  offsetY?: number;
21
+ /** DXF 9: embedded text when elementTypeFlag has bit 2 */
19
22
  text?: string;
20
23
  }
21
24
  //# sourceMappingURL=ltype.d.ts.map
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A DWG/DXF JavaScript parser based on libredwg",
4
4
  "license": "GPL-3.0",
5
5
  "private": false,
6
- "version": "0.7.11",
6
+ "version": "0.7.13",
7
7
  "author": "MLight Lee <mlight.lee@outlook.com>",
8
8
  "type": "module",
9
9
  "engines": {
Binary file