Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
taoqf committed Nov 16, 2021
2 parents 974405b + 5982489 commit 1eb1cd6
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 3,046 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dxf-parser",
"version": "1.2.0",
"version": "1.1.2",
"description": "Parse dxf files into a readable, logical js object.",
"main": "./dist/dxf-parser.js",
"module": "./dist/index.js",
Expand Down
12 changes: 12 additions & 0 deletions src/entities/arc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export interface IArcEntity extends IEntity {
startAngle: number;
endAngle: number;
angleLength: number;
extrusionDirectionX: number;
extrusionDirectionY: number;
extrusionDirectionZ: number;
}

export default class Arc implements IGeometry {
Expand All @@ -34,6 +37,15 @@ export default class Arc implements IGeometry {
entity.endAngle = Math.PI / 180 * (curr.value as number);
entity.angleLength = entity.endAngle - entity.startAngle; // angleLength is deprecated
break;
case 210:
entity.extrusionDirectionX = curr.value as number;
break;
case 220:
entity.extrusionDirectionY = curr.value as number;
break;
case 230:
entity.extrusionDirectionZ = curr.value as number;
break;
default: // ignored attribute
helpers.checkCommonEntityProperties(entity, curr, scanner);
break;
Expand Down
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ export { ISplineEntity } from './entities/spline';
export { ITextEntity } from './entities/text';
export { IVertexEntity } from './entities/vertex';

export default function parse(source: string) {
return new DxfParser().parse(source);
}
export default DxfParser
7 changes: 4 additions & 3 deletions test/DxfParser.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs';
import * as path from 'path';
import parse,{DxfParser} from '../dist/index.js';
import DxfParser from '../dist/index.js';
import should from 'should';
import approvals from 'approvals';

Expand Down Expand Up @@ -180,8 +180,9 @@ function verifyDxf(sourceFilePath) {
var sourceDirectory = path.dirname(sourceFilePath);

var file = fs.readFileSync(sourceFilePath, 'utf8');

var dxf = parse(file);

var parser = new DxfParser();
var dxf = parser.parse(file);

approvals.verifyAsJSON(sourceDirectory, baseName, dxf);
}
3 changes: 3 additions & 0 deletions test/data/arc1.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"color": 0,
"colorIndex": 0,
"endAngle": 6.197231758053196,
"extrusionDirectionX": 0,
"extrusionDirectionY": 0,
"extrusionDirectionZ": -1,
"handle": "B484",
"layer": "FG-Dtl-Dim",
"lineType": "ByBlock",
Expand Down
6 changes: 6 additions & 0 deletions test/data/arc1.dxf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ AcDbCircle
0.0
40
0.7604262403327394
210
0.0
220
0.0
230
-1.0
100
AcDbArc
50
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
],
"compileOnSave": false,
"compilerOptions": {
"module": "commonjs",
"module": "es2015",
"target": "esnext",
"jsx": "react",
"noImplicitAny": true,
Expand Down
8 changes: 5 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ module.exports = {
output: {
filename: 'dxf-parser.js',
path: path.resolve(__dirname, 'dist'),
library: 'DxfParser',
libraryTarget: 'umd',
libraryExport: 'default',
library: {
name: 'DxfParser',
type: 'umd',
export: 'DxfParser'
},
globalObject: 'typeof self !== \'undefined\' ? self : this'
}
};
3,035 changes: 0 additions & 3,035 deletions yarn.lock

This file was deleted.

0 comments on commit 1eb1cd6

Please sign in to comment.