2022-11-06 01:33:32 +01:00
|
|
|
import fs from 'fs'
|
|
|
|
import { join } from 'path'
|
|
|
|
|
|
|
|
import { Helper } from '../src'
|
|
|
|
|
2024-02-09 11:34:23 +01:00
|
|
|
const helper = new Helper(
|
|
|
|
fs.readFileSync('./test/resources/Ceco.NET-Architecture-Tm-53.dxf', 'utf-8'),
|
|
|
|
)
|
2022-11-06 01:33:32 +01:00
|
|
|
|
|
|
|
// The parsed entities
|
|
|
|
const { blocks, entities } = helper.parsed
|
|
|
|
console.log(`parsed: ${blocks.length} blocks, ${entities.length} entities.\n`)
|
|
|
|
|
|
|
|
// Denormalised blocks inserted with transforms applied
|
|
|
|
console.log(`denormalised: ${helper.denormalised.length} entities.\n`)
|
|
|
|
|
|
|
|
// Group entities by layer. Returns an object with layer names as
|
|
|
|
// keys to arrays of entities.
|
|
|
|
const groups = helper.groups
|
|
|
|
console.log('grouped entities')
|
|
|
|
console.log('----------------')
|
2024-02-09 11:34:23 +01:00
|
|
|
Object.keys(groups).forEach((layer) => {
|
2022-11-06 01:33:32 +01:00
|
|
|
console.log(`${layer}: ${groups[layer].length}`)
|
|
|
|
})
|
|
|
|
console.log('\n')
|
|
|
|
|
|
|
|
// Write the SVG
|
|
|
|
const svg = helper.toSVG()
|
|
|
|
fs.writeFileSync(join(__dirname, '/example.es6.svg'), svg, 'utf-8')
|
|
|
|
console.log('SVG written')
|