线段构建双线墙壁的dxf版本
npm install build-dxf
npm i build-dxf
`
node 使用示例
`typescript
import { DxfSystem, ModelDataPlugin, components, utils } from "build-dxf"
/**
* json 文件格式为{ start: {x: number, y: number}, end: {x: number, y: number } , insetionArr: {index: number}[] }[]
*/
const path = process.argv[2] ?? "./json/d10.json"
const dxfSystem = new DxfSystem()
// 使用模型数据生成插件
dxfSystem.usePlugin(ModelDataPlugin)
// 获取白模数据生成组件
const whiteModel = dxfSystem.findComponentByType(components.WhiteModel)
// 获取详情点数据生成组件
const detailsPoint = dxfSystem.findComponentByType(components.DetailsPoint)
const threeVJia = dxfSystem.findComponentByName("ThreeVJia")
dxfSystem.Dxf.set(path).then(()=> {
// 监听详情点数据处理完成
detailsPoint.addEventListener("handleSuccess", () => {
// 下载dxf文件
dxfSystem.Dxf.download("01.dxf")
// 下载白模,obj格式
whiteModel.downloadOBJ("001.obj")
// 下载白模,gltf或glb格式, 第二个参数为true时是glb,默认为true
whiteModel.downloadGltf("001.glb", true)
// 下载三维家 json
threeVJia.download("json.json")
// 下载为图片
dxfSystem.AngleCorrectionDxf.downloadImage("001.jpg")
// 下载新json
dxfSystem.Dxf.downloadOriginalData("data.json")
// desPoints 为射线点集合,根据需要使用
console.log("handleSuccess", detailsPoint.desPoints)
})
// trajectory222为轨迹文件数据
dxfSystem.Dxf.addEventListener("preprocessing", ({ setData, data }) => {
setData( utils.BoundExt.boundExtbyTraj(data, trajectory222 ) )
}, { once: true })
dxfSystem.Dxf.axisAlignCorr({ groupMethod: "cross", fittingMethod: "max", crossAxistThreshold: 0.08 })
dxfSystem.Dxf.lineOffset()
detailsPoint.set("./json/dp8.json")
// 获取外扩后的三维家json
const lines = utils.BoundExt.boundExtbyTraj({
lines: dxfSystem.Dxf.getLineSegments(),
trajectory: trajectoryJson // 轨迹json对象,
wallWidth: 0.12,
updateDoubleWallGroup: true
}).lines
// 三维家json
const json = utils.lineDataToThreeVJiaJson(lines, dxfSystem.AngleCorrectionDxf.angle).toJson("测试")
})
`
浏览器编辑功能使用示例
`html
`
浏览器 使用示例
`html
``