!1316 功能:检查没孔板件,命令CHECKNOHOLEBOARD 检查板件不排钻原因,命令CHECKDRAWHOLE

pull/1316/MERGE
ZoeLeeFZ 4 years ago committed by ChenX
parent 704c125b89
commit 8889a86cad

@ -0,0 +1,31 @@
import { Intent } from "@blueprintjs/core";
import { app } from "../../ApplicationServices/Application";
import { Board } from "../../DatabaseServices/Entity/Board";
import { Command } from "../../Editor/CommandMachine";
import { PromptStatus } from "../../Editor/PromptResult";
import { ShowLinesToaster } from "../../UI/Components/Toaster";
import { DrawDrillingTool } from "./DrawDrillingTool";
export class CheckDrawHole implements Command
{
async exec()
{
let ssRes = await app.Editor.GetSelection({
Msg: "选择需要检查的2块板件",
Filter: { filterTypes: [Board] }
});
if (ssRes.Status === PromptStatus.Cancel) return;
let brs = ssRes.SelectSet.SelectEntityList as Board[];
let tool = DrawDrillingTool.GetInstance() as DrawDrillingTool;
let result = await tool.Check(brs.slice(0, 2));
ShowLinesToaster(result.length === 0 ? ["没检查出无法排钻原因"] : result, {
timeout: result.length === 0 ? 3000 : 0,
intent: Intent.PRIMARY
});
}
}

@ -0,0 +1,39 @@
import { app } from "../../ApplicationServices/Application";
import { Log } from "../../Common/Log";
import { Board } from "../../DatabaseServices/Entity/Board";
import { Command } from "../../Editor/CommandMachine";
import { PromptStatus } from "../../Editor/PromptResult";
import { GetSealedBoardContour } from "../../GraphicsSystem/CalcEdgeSealing";
import { Production } from "../../Production/Product";
export class CheckHasHoleBoard implements Command
{
async exec()
{
let ssRes = await app.Editor.GetSelection({
Msg: "选择需要检查的板件",
Filter: {
filterTypes: [Board]
}
});
if (ssRes.Status === PromptStatus.Cancel) return;
let brs = ssRes.SelectSet.SelectEntityList as Board[];
const noHolesBoard: Board[] = [];
for (let br of brs)
{
let sealedContour = GetSealedBoardContour(br, true);
let outline = GetSealedBoardContour(br, false);
let offsetTanslation = outline.BoundingBox.min;
let info = Production.GetBoardHolesData(br, offsetTanslation, sealedContour);
if (info.frontBackHoles.length === 0 && info.sideHoles.length === 0)
noHolesBoard.push(br);
}
app.Viewer.OutlinePass.selectedObjects = noHolesBoard.map(e => e.DrawObject);
Log(`${noHolesBoard.length}个板件没孔`);
}
}

@ -999,4 +999,125 @@ export class DrawDrillingTool extends Singleton
} }
return false; return false;
} }
async Check(brs: Board[])
{
if (brs.length < 2) return ["板件仅一块"];
let brMap = this.ClassifyBoardList(brs);
let result: string[] = [];
for (let [, bs] of brMap)
{
if (bs.length < 2)
{
result.push("板件柜名房名与其他板件不同");
return result;
}
else
{
let checkRes = new CollisionDetection(await this.GetSpliteBoards(brs));
if (checkRes.CollisonFaces.length === 0)
{
result.push("板件没碰撞,重叠或者板件排钻属性设置不排");
}
else
{
for (let f of checkRes.CollisonFaces)
{
let suitableOptions = this.GetRuleByFace(f);
if (suitableOptions.length === 0)
{
result.push("长度" + f.Length.toFixed(2) + "没有合适的规则,或者当前配置不存在" + f.DrillType + "类型排钻");
return result;
}
for (let suitableOption of suitableOptions)
{
let notGangDist = suitableOption.notGangDist;
if (f.LocalBoard.Thickness < notGangDist - 1e-6
|| f.InterBoard.Thickness < notGangDist - 1e-6
|| f.Width < notGangDist - 1e-6)
{
result.push(`板件不排钻厚度为${notGangDist},当前碰撞面厚度太小了`);
return result;
}
if (f.Width + 0.5 < f.InterBoard.Thickness)
{
result.push(`当前碰撞面厚度为${f.Width.toFixed(2)},${f.InterBoard.Name}板件厚度为${f.InterBoard.Thickness}`);
return result;
}
if (suitableOption.count === 0)
{
result.push(`排钻个数为0`);
return result;
}
if ((!suitableOption.canSameType && f.isEqualType))
{
result.push(`当前设置同类型不排钻`);
return result;
}
//初始化排钻工具
this.InitTool(f, suitableOption);
if (suitableOption.useTemp && suitableOption.tempId)
{
let status = this.InitDrillTemp(suitableOption);
if (!status) continue;
}
else
{
this.InitDrill();
}
let key = this.CacheKey;
if (suitableOption.isDrawWood)
{
if (this._woodPinsCache.has(key))
{
this.woodPins.push(...this._woodPinsCache.get(key));
}
else
{
this.InitWoodPins();
this._woodPinsCache.set(key, this.woodPins.slice());
}
}
//获得排钻移动距离表
this.GetMoveDist();
//检查排钻列表
this.CheckDrillList(result);
}
}
}
}
}
return [...new Set(result)];
}
CheckDrillList(result: string[])
{
let { localBox3, intBox3 } = this.GetBoxes();
for (let dist of this.m_MoveDistList)
{
if (this.CheckModelingCollision(localBox3, intBox3, dist))
{
result.push(`${this.m_Face.LocalBoard.Name}-${this.m_Face.InterBoard.Name}有排钻与造型碰撞,跳过绘制`);
continue;
}
if (!this.CheckDrillInBoard(dist))
{
result.push(`${this.m_Face.LocalBoard.Name} - ${this.m_Face.InterBoard.Name}有排钻在板件外, 跳过绘制`);
continue;
}
}
}
} }

@ -184,4 +184,6 @@ export enum CommandNames
SetHoleNoneType = "SETHOLENONETYPE", SetHoleNoneType = "SETHOLENONETYPE",
FindMaxSizeBoard = "FINDMAXSIZEBOARDS", FindMaxSizeBoard = "FINDMAXSIZEBOARDS",
FindMinSizeBoard = "FINDMINSIZEBOARDS", FindMinSizeBoard = "FINDMINSIZEBOARDS",
CheckNoHoleBoard = "CHECKNOHOLEBOARD",
CheckDrawHole = "CHECKDRAWHOLE",
} }

@ -203,6 +203,8 @@ import { BuyMaterial } from './../Add-on/BuyMaterial';
import { Interfere } from './../Add-on/interfere'; import { Interfere } from './../Add-on/interfere';
import { ShowKinfeManageModal } from './../Add-on/showModal/ShowKnifeManageModal'; import { ShowKinfeManageModal } from './../Add-on/showModal/ShowKnifeManageModal';
import { commandMachine } from './CommandMachine'; import { commandMachine } from './CommandMachine';
import { CheckHasHoleBoard } from "../Add-on/DrawDrilling/CheckHasHole";
import { CheckDrawHole } from "../Add-on/DrawDrilling/CheckDrawHole";
export function registerCommand() export function registerCommand()
{ {
@ -567,6 +569,8 @@ export function registerCommand()
commandMachine.RegisterCommand(CommandNames.FindMaxSizeBoard, new FindMaxOrMinSizeBoard()); commandMachine.RegisterCommand(CommandNames.FindMaxSizeBoard, new FindMaxOrMinSizeBoard());
commandMachine.RegisterCommand(CommandNames.FindMinSizeBoard, new FindMaxOrMinSizeBoard(false)); commandMachine.RegisterCommand(CommandNames.FindMinSizeBoard, new FindMaxOrMinSizeBoard(false));
commandMachine.RegisterCommand("FindBoardModelingKnife", new Command_FindBoardModelingKnife()); commandMachine.RegisterCommand("FindBoardModelingKnife", new Command_FindBoardModelingKnife());
commandMachine.RegisterCommand(CommandNames.CheckNoHoleBoard, new CheckHasHoleBoard());
commandMachine.RegisterCommand(CommandNames.CheckDrawHole, new CheckDrawHole());
} }
export async function RegistCustomCommand() export async function RegistCustomCommand()

@ -676,6 +676,26 @@ export const CommandList: ICommand[] = [
chName: "设置板件不排钻", chName: "设置板件不排钻",
chDes: "设置板件不排钻", chDes: "设置板件不排钻",
}, },
{
icon: IconEnum.CheckDrawHole,
typeId: "pz",
link: "#",
defaultCustom: CommandNames.CheckDrawHole,
command: CommandNames.CheckDrawHole,
type: "排钻",
chName: "检测不排钻原因",
chDes: "检测不排钻原因",
},
{
icon: IconEnum.CheckNoHoleBoard,
typeId: "pz",
link: "#",
defaultCustom: CommandNames.CheckNoHoleBoard,
command: CommandNames.CheckNoHoleBoard,
type: "排钻",
chName: "检测没孔的板件",
chDes: "检测没孔的板件",
},
// { // {
// icon: IconEnum.HideDrill, // icon: IconEnum.HideDrill,
// typeId: "pz", // typeId: "pz",

@ -116,7 +116,8 @@ export class TopToolBar extends React.Component<{}, {}>
{ svg: IconEnum.DeleteDrill, title: "删除排钻", command: CommandNames.DeleteHole }, { svg: IconEnum.DeleteDrill, title: "删除排钻", command: CommandNames.DeleteHole },
{ svg: IconEnum.DrillConfig, title: "排钻配置", command: CommandNames.DrillConfig }, { svg: IconEnum.DrillConfig, title: "排钻配置", command: CommandNames.DrillConfig },
{ svg: IconEnum.CheckHole, title: "排钻碰撞检查", command: CommandNames.CheckHoles }, { svg: IconEnum.CheckHole, title: "排钻碰撞检查", command: CommandNames.CheckHoles },
// { svg: IconEnum.HideDrill, title: "隐藏排钻", command: "" }, { svg: IconEnum.CheckDrawHole, title: "检测不排钻原因", command: CommandNames.CheckDrawHole },
{ svg: IconEnum.CheckNoHoleBoard, title: "检测没孔板件", command: CommandNames.CheckNoHoleBoard },
]; ];
store.iconList.view = [ store.iconList.view = [
{ svg: IconEnum.UCS, title: "UCS", command: CommandNames.CustomUCS }, { svg: IconEnum.UCS, title: "UCS", command: CommandNames.CustomUCS },

@ -179,4 +179,6 @@ export enum IconEnum
ShowFrame = "SHOWFRAME.svg", ShowFrame = "SHOWFRAME.svg",
OneKeyLayout = "ONEKEYLAYOUT.svg", OneKeyLayout = "ONEKEYLAYOUT.svg",
OneKeyPrint = "ONEKEYPRINT.svg", OneKeyPrint = "ONEKEYPRINT.svg",
CheckNoHoleBoard = "CHECKNOHOLEBOARD.svg",
CheckDrawHole = "CHECKDRAWHOLE.svg",
} }

Loading…
Cancel
Save