mirror of https://gitee.com/cf-fz/WebCAD.git
!2312 功能:板添加排钻锁定功能
parent
20536fc8d3
commit
b145c09fa4
@ -0,0 +1,45 @@
|
|||||||
|
import { Intent } from "@blueprintjs/core";
|
||||||
|
import { app } from "../../../ApplicationServices/Application";
|
||||||
|
import { Board } from "../../../DatabaseServices/Entity/Board";
|
||||||
|
import { Command } from "../../../Editor/CommandMachine";
|
||||||
|
import { AppToaster } from "../../../UI/Components/Toaster";
|
||||||
|
|
||||||
|
export class AllDrillUnlock implements Command
|
||||||
|
{
|
||||||
|
async exec()
|
||||||
|
{
|
||||||
|
//所有存在排钻锁的板
|
||||||
|
const associationBoards = app.Database.ModelSpace.Entitys.filter(br =>
|
||||||
|
{
|
||||||
|
if (!br.IsErase && br instanceof Board)
|
||||||
|
{
|
||||||
|
if (br.DrillLock === true || br.DrillAssociationLock.size > 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}) as Board[];
|
||||||
|
|
||||||
|
if (associationBoards.length)
|
||||||
|
{
|
||||||
|
for (const associationBoard of associationBoards)
|
||||||
|
{
|
||||||
|
associationBoard.ClearAllDrillLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
AppToaster.show({
|
||||||
|
message: `解除所有排钻锁成功`,
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
|
timeout: 3000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AppToaster.show({
|
||||||
|
message: `当前没有板设置了排钻锁`,
|
||||||
|
intent: Intent.WARNING,
|
||||||
|
timeout: 3000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
import { Intent } from "@blueprintjs/core";
|
||||||
|
import { app } from "../../../ApplicationServices/Application";
|
||||||
|
import { Log, LogType } from "../../../Common/Log";
|
||||||
|
import { Board } from "../../../DatabaseServices/Entity/Board";
|
||||||
|
import { Command } from "../../../Editor/CommandMachine";
|
||||||
|
import { PromptStatus } from "../../../Editor/PromptResult";
|
||||||
|
import { AppToaster } from "../../../UI/Components/Toaster";
|
||||||
|
|
||||||
|
export class AssociationLock implements Command
|
||||||
|
{
|
||||||
|
async exec()
|
||||||
|
{
|
||||||
|
const BoardRes = await app.Editor.GetEntity({
|
||||||
|
Msg: "请选择锁定排钻的板",
|
||||||
|
Filter: { filterTypes: [Board] }
|
||||||
|
});
|
||||||
|
if (BoardRes.Status !== PromptStatus.OK) return;
|
||||||
|
const FirstBoard = BoardRes.Entity as Board;
|
||||||
|
const FirstBoardId = FirstBoard.Id;
|
||||||
|
|
||||||
|
const drillAssociationLock = FirstBoard.DrillAssociationLock;
|
||||||
|
const associationBoards = [...drillAssociationLock].map(o => o.Object as Board); //读取第一块板关联锁定的板集合
|
||||||
|
const existAssociationBoards = associationBoards.filter(br => !br.IsErase); //存在的板
|
||||||
|
|
||||||
|
if (existAssociationBoards.length)
|
||||||
|
{
|
||||||
|
app.Editor.SetSelection(existAssociationBoards); //亮显关联的板
|
||||||
|
AppToaster.show({
|
||||||
|
message: `当前板已存在${existAssociationBoards.length}块关联的板,已显示当前关联过的板`,
|
||||||
|
intent: Intent.PRIMARY,
|
||||||
|
timeout: 3000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const associationBoardRes = await app.Editor.GetSelection({
|
||||||
|
Msg: "请选择需要关联锁定排钻的板",
|
||||||
|
Filter: {
|
||||||
|
filterTypes: [Board],
|
||||||
|
filterFunction: (obj, ent) =>
|
||||||
|
{
|
||||||
|
if (ent.Id === FirstBoardId)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (associationBoardRes.Status === PromptStatus.OK)
|
||||||
|
{
|
||||||
|
const associationBoards = associationBoardRes.SelectSet.SelectEntityList as Board[];
|
||||||
|
for (const associationBoard of associationBoards)
|
||||||
|
{
|
||||||
|
const associationBoardId = associationBoard.Id;
|
||||||
|
FirstBoard.AppendDrillAssociationLock(associationBoardId);
|
||||||
|
|
||||||
|
associationBoard.AppendDrillAssociationLock(FirstBoardId);
|
||||||
|
}
|
||||||
|
|
||||||
|
AppToaster.show({
|
||||||
|
message: `排钻关联锁定成功,共关联了${associationBoards.length}块板`,
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
|
timeout: 3000,
|
||||||
|
});
|
||||||
|
Log(`排钻关联锁定成功,共关联了${associationBoards.length}块板`, LogType.Info, [...associationBoards]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,105 @@
|
|||||||
|
import { app } from "../../../ApplicationServices/Application";
|
||||||
|
import { Log, LogType } from "../../../Common/Log";
|
||||||
|
import { Intent } from "../../../Common/Toaster";
|
||||||
|
import { Board } from "../../../DatabaseServices/Entity/Board";
|
||||||
|
import { Command } from "../../../Editor/CommandMachine";
|
||||||
|
import { PromptStatus } from "../../../Editor/PromptResult";
|
||||||
|
import { AppToaster } from "../../../UI/Components/Toaster";
|
||||||
|
|
||||||
|
export class AssociationUnlock implements Command
|
||||||
|
{
|
||||||
|
async exec()
|
||||||
|
{
|
||||||
|
const associationBoardIndex = app.Database.ModelSpace.Entitys.findIndex(ent =>
|
||||||
|
{
|
||||||
|
if (!ent.IsErase && ent instanceof Board)
|
||||||
|
{
|
||||||
|
return Boolean(ent.DrillAssociationLock.size);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (associationBoardIndex === -1)
|
||||||
|
{
|
||||||
|
AppToaster.show({
|
||||||
|
message: "不存在关联排钻锁定的板",
|
||||||
|
intent: Intent.WARNING,
|
||||||
|
timeout: 2000,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
const BoardRes = await app.Editor.GetEntity({
|
||||||
|
Msg: "请选择解除排钻锁定的板",
|
||||||
|
Filter: { filterTypes: [Board] }
|
||||||
|
});
|
||||||
|
if (BoardRes.Status !== PromptStatus.OK) return;
|
||||||
|
const FirstBoard = BoardRes.Entity as Board;
|
||||||
|
|
||||||
|
const drillAssociationLock = FirstBoard.DrillAssociationLock;
|
||||||
|
const associationBoards = [...drillAssociationLock.values()].map(o => o.Object as Board); //读取第一块板关联锁定的板集合
|
||||||
|
|
||||||
|
if (!associationBoards.length)
|
||||||
|
{
|
||||||
|
AppToaster.show({
|
||||||
|
message: "当前板不存在关联排钻锁定的板",
|
||||||
|
intent: Intent.WARNING,
|
||||||
|
timeout: 2000,
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
const DisassociateBoardRes = await app.Editor.GetSelection({
|
||||||
|
Msg: "请选择需要解除关联锁定的板",
|
||||||
|
Filter: {
|
||||||
|
filterTypes: [Board],
|
||||||
|
filterFunction: (obj, ent) =>
|
||||||
|
{
|
||||||
|
return associationBoards.some(br => br.objectId === ent.objectId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
KeyWordList: [{ key: "A", msg: "选中所有关联的板" }]
|
||||||
|
});
|
||||||
|
|
||||||
|
if (DisassociateBoardRes.Status === PromptStatus.Keyword)
|
||||||
|
{
|
||||||
|
if (DisassociateBoardRes.StringResult === "A")
|
||||||
|
{
|
||||||
|
app.Editor.SetSelection(associationBoards); //亮显关联的板
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (DisassociateBoardRes.Status === PromptStatus.OK)
|
||||||
|
{
|
||||||
|
const disassociateBoards = DisassociateBoardRes.SelectSet.SelectEntityList as Board[]; //取消关联的板
|
||||||
|
DisassociateBoard(disassociateBoards, FirstBoard);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//解除板排钻锁关联
|
||||||
|
function DisassociateBoard(brs: Board[], FirstBoard: Board)
|
||||||
|
{
|
||||||
|
for (const br of brs)
|
||||||
|
{
|
||||||
|
const associationBoardId = br.Id;
|
||||||
|
FirstBoard.ClearDrillAssociationLock(associationBoardId);
|
||||||
|
|
||||||
|
br.ClearDrillAssociationLock(FirstBoard.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
AppToaster.show({
|
||||||
|
message: `排钻关联解除锁定成功,共解除了${brs.length}块板`,
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
|
timeout: 3000,
|
||||||
|
});
|
||||||
|
Log(`排钻关联解除锁定成功,共解除了${brs.length}块板`, LogType.Info, [...brs]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
import { Intent } from "@blueprintjs/core";
|
||||||
|
import { app } from "../../../ApplicationServices/Application";
|
||||||
|
import { Log, LogType } from "../../../Common/Log";
|
||||||
|
import { Board } from "../../../DatabaseServices/Entity/Board";
|
||||||
|
import { Command } from "../../../Editor/CommandMachine";
|
||||||
|
import { PromptStatus } from "../../../Editor/PromptResult";
|
||||||
|
import { AppToaster } from "../../../UI/Components/Toaster";
|
||||||
|
|
||||||
|
export class IndependentLockAndUnLock implements Command
|
||||||
|
{
|
||||||
|
private isLock: boolean;
|
||||||
|
constructor(isLock: boolean)
|
||||||
|
{
|
||||||
|
this.isLock = isLock;
|
||||||
|
}
|
||||||
|
async exec()
|
||||||
|
{
|
||||||
|
const lockBoards = app.Database.ModelSpace.Entitys.filter(ent =>
|
||||||
|
{
|
||||||
|
if (!ent.IsErase && ent instanceof Board)
|
||||||
|
{
|
||||||
|
return Boolean(ent.DrillLock === true);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}) as Board[];
|
||||||
|
|
||||||
|
if (this.isLock)
|
||||||
|
{
|
||||||
|
if (lockBoards.length)
|
||||||
|
{
|
||||||
|
app.Editor.SetSelection(lockBoards); //亮显关联的板
|
||||||
|
|
||||||
|
AppToaster.show({
|
||||||
|
message: `已存在${lockBoards.length}块排钻锁定的板,以显示锁定的板`,
|
||||||
|
intent: Intent.PRIMARY,
|
||||||
|
timeout: 3000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let brRes = await app.Editor.GetSelection({
|
||||||
|
Msg: "请选择需要排钻锁定的板",
|
||||||
|
Filter: { filterTypes: [Board] },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (brRes.Status === PromptStatus.OK)
|
||||||
|
{
|
||||||
|
const brs = brRes.SelectSet.SelectEntityList as Board[];
|
||||||
|
for (let ent of brs)
|
||||||
|
{
|
||||||
|
ent.DrillLock = this.isLock;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppToaster.show({
|
||||||
|
message: `成功锁定${brs.length}块板`,
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
|
timeout: 3000,
|
||||||
|
});
|
||||||
|
Log(`成功锁定${brs.length}块板`, LogType.Info, [...brs]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!lockBoards.length)
|
||||||
|
{
|
||||||
|
AppToaster.show({
|
||||||
|
message: `当前图纸没有排钻锁定的板`,
|
||||||
|
intent: Intent.WARNING,
|
||||||
|
timeout: 3000,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
let brRes = await app.Editor.GetSelection({
|
||||||
|
Msg: "请选择需要解除排钻锁定的板",
|
||||||
|
Filter: {
|
||||||
|
filterTypes: [Board],
|
||||||
|
filterFunction: (obj, ent) =>
|
||||||
|
{
|
||||||
|
return (ent as Board).DrillLock;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
KeyWordList: [{ key: "A", msg: "选中所有已锁定排钻的板" }]
|
||||||
|
});
|
||||||
|
|
||||||
|
if (brRes.Status === PromptStatus.Keyword)
|
||||||
|
{
|
||||||
|
if (brRes.StringResult === "A")
|
||||||
|
{
|
||||||
|
app.Editor.SetSelection(lockBoards); //亮显关联的板
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (brRes.Status === PromptStatus.OK)
|
||||||
|
{
|
||||||
|
const brs = brRes.SelectSet.SelectEntityList as Board[];
|
||||||
|
for (let ent of brs)
|
||||||
|
{
|
||||||
|
ent.DrillLock = this.isLock;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppToaster.show({
|
||||||
|
message: `成功解除锁定${brs.length}块板`,
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
|
timeout: 3000,
|
||||||
|
});
|
||||||
|
Log(`成功解除锁定${brs.length}块板`, LogType.Info, [...brs]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue