!2697 优化:晨丰接口导入可以拖拽导入

pull/2636/MERGE
黄诗津 5 months ago committed by ChenX
parent e69370f6ba
commit e3b782aaed

@ -24,37 +24,42 @@ export class ImportCFData implements Command
for (let i = 0; i < files.length; i++)
{
let file = files.item(i);
let data = await file.text();
try
{
let doc = JSON.parse(data);
if (doc.ModelSpace)
{
await ParseCFDoc(doc, app.Database);
}
else
{
AppToaster.show({
message: `${file.name}不是有效的晨丰JSON文件!`,
timeout: 5000,
intent: Intent.WARNING,
});
}
}
catch (error)
{
AppToaster.show({
message: `${file.name}导入失败!`,
timeout: 5000,
intent: Intent.WARNING,
});
}
await ImportCFFile(file);
}
}
});
}
}
export async function ImportCFFile(file: File)
{
let data = await file.text();
try
{
let doc = JSON.parse(data);
if (doc.ModelSpace)
{
await ParseCFDoc(doc, app.Database);
}
else
{
AppToaster.show({
message: `${file.name}不是有效的晨丰JSON文件!`,
timeout: 5000,
intent: Intent.WARNING,
});
}
}
catch (error)
{
AppToaster.show({
message: `${file.name}导入失败!`,
timeout: 5000,
intent: Intent.WARNING,
});
}
}
export async function ParseCFDoc(document: ICFDoc, cuDb: Database)
{
await CommandWrap(async () =>

@ -161,8 +161,8 @@ export interface ICFTopline extends ICFTemplate
Spec?: string; //规格
Comments?: string; //备注
Contour?: { pt: [number, number], bul: 0; }[]; //横截面轮廓曲线
PathCurve?: ICFExtrudeContour; //绘制路径曲线
Contour?: ICFPolylineContour; //横截面轮廓曲线
PathCurve?: ICFExtrudeContour; //绘制路径曲线
}
@ -182,7 +182,7 @@ export interface ICFLine extends ICFCurve
export interface ICFPolyline extends ICFCurve
{
// Type: "Polyline"; //类型多段线(必填)
ContourCurve?: { pt: [number, number], bul: 0; }[]; //轮廓曲线
ContourCurve?: ICFPolylineContour; //轮廓曲线
}
export interface ICFRect extends ICFCurve

@ -8,10 +8,11 @@ type EntityType = "Entity" | "ExtrudeSolid" | "Board" | "Template" | "EntityTree
// pt为点坐标,bul为弯曲度(区间-1~1),俗称弓弦比
// bul为0时为直线,bul为0.5时为半圆,正负为上下弯曲的方向
// bul值为(弧线两点直线的中点到弧线中点的距离)除以(弧线两点直线的中点到弧线起点的距离)
type PolylineContour = { pt: [number, number], bul: 0; }[]; //多段线轮廓
type CircleContour = { Radius: number, Center: [number, number, number]; }; //圆形轮廓
type ExtrudeContour = PolylineContour | CircleContour;
type ICFPolylineContour = { pt: [number, number], bul: 0; }[]; //多段线轮廓
type ICFCircleContour = { Radius: number, Center: [number, number, number]; }; //圆形轮廓
type ICFExtrudeContour = ICFPolylineContour | ICFCircleContour;
图纸结构
1.模型空间 ModelSpace 结构
@ -73,7 +74,7 @@ type ExtrudeContour = PolylineContour | CircleContour;
Width?: number; //宽
Height?: number; //高
// Or
ContourCurve?: ExtrudeContour; //轮廓曲线
ContourCurve?: ICFExtrudeContour; //轮廓曲线
Thickness?: number; //厚度
GroovesAddLength?: number; //槽加长
@ -354,7 +355,7 @@ type ExtrudeContour = PolylineContour | CircleContour;
Comments?: string; //备注
Contour?: { pt: [number, number], bul: 0; }[]; //横截面轮廓曲线
PathCurve?: ExtrudeContour; //绘制路径曲线
PathCurve?: ICFExtrudeContour; //绘制路径曲线
}
例1:

@ -3,6 +3,7 @@ import hotkeys from 'hotkeys-js-ext';
import { MathUtils, Matrix4, Object3D, PerspectiveCamera, Vector3 } from 'three';
import { begin, end } from 'xaop';
import { HardwareCuttingReactor } from '../Add-on/BoardCutting/HardwareCuttingReactor';
import { ImportCFFile } from '../Add-on/CF/Import/CFImport';
import { DwgDxfImport } from '../Add-on/DXFLoad';
import { DrillingReactor } from '../Add-on/DrawDrilling/DrillingReactor';
import { AppendUserInfo } from '../Add-on/ExportData';
@ -419,6 +420,8 @@ export class ApplicationService
if (obj.paramModel)
if (tpStore.canKJLImport)
await ImportKJLData(obj);
if (obj.ModelSpace)
await ImportCFFile(f);
}
}
if (xmlFiles.length)

Loading…
Cancel
Save