|
|
|
@ -1,14 +1,19 @@
|
|
|
|
|
import { Box3, Matrix4, Vector3 } from "three";
|
|
|
|
|
import { app } from "../../../ApplicationServices/Application";
|
|
|
|
|
import { arrayRemoveIf } from "../../../Common/ArrayExt";
|
|
|
|
|
import { EBoardKeyList } from "../../../Common/BoardKeyList";
|
|
|
|
|
import { FS } from "../../../Common/FileSystem";
|
|
|
|
|
import { MaterialUrls } from "../../../Common/HostUrl";
|
|
|
|
|
import { JigMoveEntity } from "../../../Common/JigMove";
|
|
|
|
|
import { Log, LogType } from "../../../Common/Log";
|
|
|
|
|
import { MakeMirrorMtx, NormalMatrix } from "../../../Common/Matrix4Utils";
|
|
|
|
|
import { PostJson, RequestStatus } from "../../../Common/Request";
|
|
|
|
|
import { MaterialIn } from "../../../Common/SerializeMaterial";
|
|
|
|
|
import { DuplicateRecordCloning } from "../../../Common/Status";
|
|
|
|
|
import { Intent, ToasterShowEntityMsg } from "../../../Common/Toaster";
|
|
|
|
|
import { FixDigits } from "../../../Common/Utils";
|
|
|
|
|
import { safeEval } from "../../../Common/eval";
|
|
|
|
|
import { inflateBase64 } from "../../../Common/inflate";
|
|
|
|
|
import { Contour } from "../../../DatabaseServices/Contour";
|
|
|
|
|
import { Database } from "../../../DatabaseServices/Database";
|
|
|
|
|
import { Arc } from "../../../DatabaseServices/Entity/Arc";
|
|
|
|
@ -19,7 +24,9 @@ import { Line } from "../../../DatabaseServices/Entity/Line";
|
|
|
|
|
import { Polyline } from "../../../DatabaseServices/Entity/Polyline";
|
|
|
|
|
import { HardwareCompositeEntity } from "../../../DatabaseServices/Hardware/HardwareCompositeEntity";
|
|
|
|
|
import { ObjectId } from "../../../DatabaseServices/ObjectId";
|
|
|
|
|
import { PhysicalMaterialRecord } from "../../../DatabaseServices/PhysicalMaterialRecord";
|
|
|
|
|
import { Shape } from "../../../DatabaseServices/Shape";
|
|
|
|
|
import { TemplateParamType } from "../../../DatabaseServices/Template/Param/TemplateParamType";
|
|
|
|
|
import { GetOnlineTemplate } from "../../../DatabaseServices/Template/TempateUtils";
|
|
|
|
|
import { TemplateRecord } from "../../../DatabaseServices/Template/TemplateRecord";
|
|
|
|
|
import { Command, CommandWrap } from "../../../Editor/CommandMachine";
|
|
|
|
@ -200,25 +207,32 @@ class JiaJuParse
|
|
|
|
|
let template_out = await GetOnlineTemplate(paramTable.ID);
|
|
|
|
|
if (template_out)
|
|
|
|
|
{
|
|
|
|
|
template_out = template_out.Root;
|
|
|
|
|
template = app.Database.WblockCloneObejcts([template_out], app.Database.TemplateTable, new Map(), DuplicateRecordCloning.Ignore)[0] as TemplateRecord;
|
|
|
|
|
|
|
|
|
|
template_out.LParam.expr = paramTable.W;
|
|
|
|
|
template_out.WParam.expr = paramTable.D;
|
|
|
|
|
template_out.HParam.expr = paramTable.H;
|
|
|
|
|
template = template.Root;
|
|
|
|
|
|
|
|
|
|
template.LParam.expr = paramTable.W;
|
|
|
|
|
template.WParam.expr = paramTable.D;
|
|
|
|
|
template.HParam.expr = paramTable.H;
|
|
|
|
|
|
|
|
|
|
for (let paramName in paramTable)
|
|
|
|
|
{
|
|
|
|
|
if (paramName.startsWith("MK_"))
|
|
|
|
|
{
|
|
|
|
|
let param = template_out.GetParam(paramName);
|
|
|
|
|
let param = template.GetParam(paramName);
|
|
|
|
|
if (param)
|
|
|
|
|
param.expr = paramTable[paramName];
|
|
|
|
|
else
|
|
|
|
|
Log(`AB库应用参数失败,参数:${paramName}`, LogType.Error);
|
|
|
|
|
{
|
|
|
|
|
if (param.type === TemplateParamType.Material)
|
|
|
|
|
param.MaterialValue = await LoadMaterial(paramTable[paramName]);
|
|
|
|
|
else if (param.type === TemplateParamType.Float)
|
|
|
|
|
param.expr = paramTable[paramName];
|
|
|
|
|
else
|
|
|
|
|
Log(`AB库应用参数失败,参数:${paramName}`, LogType.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let ens = template_out.AllEntitys as Entity[];
|
|
|
|
|
let ens = template.AllEntitys as Entity[];
|
|
|
|
|
for (const en of ens)
|
|
|
|
|
{
|
|
|
|
|
if (en instanceof Board)
|
|
|
|
@ -279,7 +293,7 @@ class JiaJuParse
|
|
|
|
|
|
|
|
|
|
let openType = parseInt(paramTable.OPEN_TYPE);
|
|
|
|
|
let openDoorString = GetHardwareOpenDir(openType);
|
|
|
|
|
for (let e of template_out.AllEntitys)
|
|
|
|
|
for (let e of template.AllEntitys)
|
|
|
|
|
{
|
|
|
|
|
if (e instanceof Board)
|
|
|
|
|
e.OpenDir = openType;
|
|
|
|
@ -291,14 +305,14 @@ class JiaJuParse
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await template_out.UpdateTemplateTree();
|
|
|
|
|
await template.UpdateTemplateTree();
|
|
|
|
|
|
|
|
|
|
// 删除材质变量 避免重复进入(在酷家乐导入后删除这个是可以接受的!)(或者不删除也是可以接受的, 但是要把材质Value设置为空);
|
|
|
|
|
arrayRemoveIf(template.Params, p => p.type === TemplateParamType.Material);
|
|
|
|
|
|
|
|
|
|
let mtx = new Matrix4().fromArray(product.Coordinate.split(",").map(parseFloat));
|
|
|
|
|
for (let ent of template_out.AllEntitys)
|
|
|
|
|
for (let ent of template.AllEntitys)
|
|
|
|
|
ent.ApplyMatrix(mtx);
|
|
|
|
|
|
|
|
|
|
template = this.curDb.WblockCloneObejcts([template_out], this.curDb.TemplateTable, new Map(), DuplicateRecordCloning.Ignore)[0] as TemplateRecord;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -594,3 +608,41 @@ function JiajuPath2Polyline(path: JiaJu.Path)
|
|
|
|
|
|
|
|
|
|
return polyline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function LoadMaterial(fetchMaterialId: string): Promise<PhysicalMaterialRecord>
|
|
|
|
|
{
|
|
|
|
|
let mtl: PhysicalMaterialRecord;
|
|
|
|
|
|
|
|
|
|
let data = await PostJson(MaterialUrls.detail, { material_id: fetchMaterialId });
|
|
|
|
|
if (data.err_code !== RequestStatus.Ok)
|
|
|
|
|
{
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: `错误:无法从远程获取到材质数据!id:${fetchMaterialId}`,
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
intent: Intent.DANGER,
|
|
|
|
|
}, "no_mtl_data");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
let jsonData = JSON.parse(inflateBase64(data.materials.file));
|
|
|
|
|
let mtlOut = MaterialIn(jsonData) as PhysicalMaterialRecord;
|
|
|
|
|
mtl = app.Database.WblockCloneObejcts(
|
|
|
|
|
[mtlOut],
|
|
|
|
|
app.Database.MaterialTable,
|
|
|
|
|
new Map(),
|
|
|
|
|
DuplicateRecordCloning.Ignore
|
|
|
|
|
)[0] as PhysicalMaterialRecord;
|
|
|
|
|
|
|
|
|
|
return mtl;
|
|
|
|
|
}
|
|
|
|
|
catch (error)
|
|
|
|
|
{
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: `加载材质失败! id:${fetchMaterialId}`,
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
intent: Intent.WARNING,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|