mirror of https://gitee.com/cf-fz/WebCAD.git
!1111 功能:根据板材修改颜色,命令CHANGECOLORBYMAT
parent
a4546dde91
commit
ae7d9f3e01
@ -0,0 +1,36 @@
|
|||||||
|
import { Command } from "../Editor/CommandMachine";
|
||||||
|
import { app } from "../ApplicationServices/Application";
|
||||||
|
import { Board } from "../DatabaseServices/Entity/Board";
|
||||||
|
import { PromptStatus } from "../Editor/PromptResult";
|
||||||
|
import { EBoardKeyList } from "../Common/BoardKeyList";
|
||||||
|
|
||||||
|
export class ChangeColorByMaterial implements Command
|
||||||
|
{
|
||||||
|
async exec()
|
||||||
|
{
|
||||||
|
let brRes = await app.Editor.GetSelection({
|
||||||
|
Msg: "选择板件,根据板材名称修改颜色",
|
||||||
|
Filter: { filterTypes: [Board] }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (brRes.Status === PromptStatus.Cancel) return;
|
||||||
|
|
||||||
|
let brs = brRes.SelectSet.SelectEntityList as Board[];
|
||||||
|
|
||||||
|
let cache: string[] = [];
|
||||||
|
|
||||||
|
for (let br of brs)
|
||||||
|
{
|
||||||
|
let key = `${br.BoardProcessOption[EBoardKeyList.BrMat]}-${br.BoardProcessOption[EBoardKeyList.Color]}-${br.BoardProcessOption[EBoardKeyList.Mat]}`;
|
||||||
|
let color = cache.indexOf(key);
|
||||||
|
if (color === -1)
|
||||||
|
{
|
||||||
|
color = cache.length + 1;
|
||||||
|
cache.push(key);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
color += 1;
|
||||||
|
br.ColorIndex = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue