mirror of https://gitee.com/cf-fz/WebCAD.git
!2525 功能:一键建模 命令:Modeling
parent
b910d02332
commit
2387dcb32e
@ -0,0 +1,61 @@
|
||||
import { Intent } from "@blueprintjs/core";
|
||||
import { app } from "../ApplicationServices/Application";
|
||||
import { GroupEntitysByBox } from "../Common/GroupEntitysByBox";
|
||||
import { Board } from "../DatabaseServices/Entity/Board";
|
||||
import { Entity } from "../DatabaseServices/Entity/Entity";
|
||||
import { HardwareCompositeEntity } from "../DatabaseServices/Hardware/HardwareCompositeEntity";
|
||||
import { InitTempateBoardThicknessActions, InitTempateSizeActions, InitTemplate } from "../DatabaseServices/Template/TempateUtils";
|
||||
import { Command } from "../Editor/CommandMachine";
|
||||
import { PromptStatus } from "../Editor/PromptResult";
|
||||
import { AppToaster } from "../UI/Components/Toaster";
|
||||
|
||||
export class Command_Modeling implements Command
|
||||
{
|
||||
async exec()
|
||||
{
|
||||
let enRes = await app.Editor.GetSelection({
|
||||
Filter: { filterTypes: [Entity] },
|
||||
Msg: "选择板件"
|
||||
});
|
||||
if (enRes.Status !== PromptStatus.OK) return;
|
||||
|
||||
let brs = enRes.SelectSet.SelectEntityList as Entity[];
|
||||
let box2entitys_map = GroupEntitysByBox(brs);
|
||||
|
||||
AppToaster.show({
|
||||
message: "选择的实体存在多个模块时,将忽略原先模块!",
|
||||
timeout: 5000,
|
||||
intent: Intent.PRIMARY,
|
||||
}, "modeling_tip");
|
||||
|
||||
for (let [box, ents] of box2entitys_map)
|
||||
{
|
||||
if (ents.length < 2) continue;
|
||||
|
||||
//按实体的绘制顺序
|
||||
ents.sort((a, b) => a.objectId?.Index - b.objectId?.Index);
|
||||
//初始化模块
|
||||
let newTemp = await InitTemplate(ents, true);
|
||||
//初始化模块的大小动作
|
||||
InitTempateSizeActions(newTemp, false);
|
||||
//初始化模块的板厚动作
|
||||
await InitTempateBoardThicknessActions(newTemp, true);
|
||||
|
||||
//模块名称使用柜名
|
||||
let tempName = "";
|
||||
for (let ent of ents)
|
||||
{
|
||||
if (ent instanceof Board)
|
||||
tempName = ent.BoardProcessOption.cabinetName;
|
||||
else if (ent instanceof HardwareCompositeEntity)
|
||||
tempName = ent.HardwareOption.cabinetName;
|
||||
if (tempName)
|
||||
{
|
||||
newTemp.Name = tempName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
app.Editor.SetSelection(brs);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue