!2083 新增:新增特性匹配命令 matchprop #481

pull/2084/MERGE
林三 2 years ago committed by ChenX
parent 70a91c813d
commit dc3af49127

@ -32,7 +32,6 @@ export class CuttingByFace implements Command
for (let [contour, useCurves] of useCurvesMap)
{
JigUtils.Destroy();
let isInput = false;
let en = JigUtils.Draw(new ExtrudeSolid());
en.KnifeRadius = currentRadius;
let appleMat = ExtrudeApplyContour(en, contour);
@ -61,67 +60,52 @@ export class CuttingByFace implements Command
while (true)
{
if (isInput)
{
let radius = await this.GetKnifeRadius(currentRadius);
if (radius)
let dir = 1;
let distRes = await app.Editor.GetDistance({
Msg: "输入切割的高度<空格全切>:",
BasePoint: basePt,
KeyWordList: [{ msg: `刀半径(${(currentRadius)}mm)`, key: "D" }],
CalcDistance: (p: Vector3, p2: Vector3) =>
{
isInput = false;
currentRadius = radius;
en.KnifeRadius = currentRadius;
}
else
dir = plane.distanceToPoint(p2);
return dir;
},
Callback: (d) =>
{
app.Editor.UCSMatrix = oldUcs;
break;
this.setHeight(en, d, oldPosition);
}
});
if (distRes.Status === PromptStatus.OK)
{
let dist = distRes.Distance;
if (Math.sign(dir) !== Math.sign(dist))
dist = -dist;
this.setHeight(en, dist, oldPosition);
for (let br of meatsBrs)
br.Subtract([en]);
for (let c of useCurves)
c.Erase();
}
else
else if (distRes.Status === PromptStatus.None)//全切
{
let dir = 1;
let distRes = await app.Editor.GetDistance({
Msg: "输入切割的高度<空格全切>:",
BasePoint: basePt,
KeyWordList: [{ msg: `刀半径(${(currentRadius)}mm)`, key: "D" }],
CalcDistance: (p: Vector3, p2: Vector3) =>
{
dir = plane.distanceToPoint(p2);
return dir;
},
Callback: (d) =>
{
this.setHeight(en, d, oldPosition);
}
});
if (distRes.Status === PromptStatus.OK)
{
let dist = distRes.Distance;
if (Math.sign(dir) !== Math.sign(dist))
dist = -dist;
this.setHeight(en, dist, oldPosition);
for (let br of meatsBrs)
{
br.Subtract([en]);
}
for (let c of useCurves)
c.Erase();
}
else if (distRes.Status === PromptStatus.None)
{
en.Thickness = 5000 * 2;
en.Position = oldPosition.add(en.Normal.multiplyScalar(-5000));
for (let br of meatsBrs)
br.Subtract([en]);
for (let c of useCurves)
c.Erase();
}
else if (distRes.Status === PromptStatus.Keyword)
en.Thickness = 5000 * 2;
en.Position = oldPosition.add(en.Normal.multiplyScalar(-5000));
for (let br of meatsBrs)
br.Subtract([en]);
for (let c of useCurves)
c.Erase();
}
else if (distRes.Status === PromptStatus.Keyword)//输入刀半径
{
let radius = await this.GetKnifeRadius(currentRadius);
if (radius)
{
isInput = true;
currentRadius = radius;
en.KnifeRadius = currentRadius;
continue;
}
break;
}
break;
}
}
@ -161,46 +145,34 @@ export class CuttingByFace implements Command
}
private async GetMeatsBoards(currentRadius: number)
{
let isInput = false;
let meatsBrs: Board[];
while (true)
{
if (isInput)
let meatBrsSsRes = await app.Editor.GetSelection({
Msg: "选择要被切割的板件<空格全选>",
Filter: { filterTypes: [Board] },
AllowNone: true,
KeyWordList: [{ msg: `刀半径(${(currentRadius)}mm)`, key: "D" }],
});
if (meatBrsSsRes.Status === PromptStatus.OK)
{
let meatsBrs = meatBrsSsRes.SelectSet.SelectEntityList as Board[];
return { currentRadius, meatsBrs };
}
else if (meatBrsSsRes.Status === PromptStatus.Other)//全选
{
let meatsBrs = app.Database.ModelSpace.Entitys.filter(e => !e.IsErase && e instanceof Board) as Board[];
return { currentRadius, meatsBrs };
}
else if (meatBrsSsRes.Status === PromptStatus.Keyword)//输入刀半径
{
let radius = await this.GetKnifeRadius(currentRadius);
if (radius)
{
currentRadius = radius;
isInput = false;
}
else
return;
}
else
{
let sBr = await app.Editor.GetSelection({
Msg: "选择要被切割的板件<空格全选>",
Filter: { filterTypes: [Board] },
AllowNone: true,
KeyWordList: [{ msg: `刀半径(${(currentRadius)}mm)`, key: "D" }],
});
if (sBr.Status === PromptStatus.OK)
{
meatsBrs = sBr.SelectSet.SelectEntityList as Board[];
return { currentRadius, meatsBrs };
}
else if (sBr.Status === PromptStatus.None)
{
meatsBrs = app.Database.ModelSpace.Entitys.filter(e => !e.IsErase && e instanceof Board) as Board[];
return { currentRadius, meatsBrs };
}
else if (sBr.Status === PromptStatus.Keyword)
{
isInput = true;
}
else return;
}
else return;
}
}
}

@ -81,7 +81,7 @@ async function SelectEntitys(useExtrude = false, Once = true): Promise<ExtrudeCo
Once
});
if (ssRes.Status === PromptStatus.None)
if (ssRes.Status === PromptStatus.Other)
{
ssRes.Status = PromptStatus.OK;
ssRes.SelectSet = new SelectSet();

@ -10,7 +10,7 @@ export class FindMaxOrMinSizeBoard implements Command
constructor(private findMax = true) { }
async exec()
{
let enRes = await app.Editor.GetSelection({
let ssRes = await app.Editor.GetSelection({
Msg: "选择板件<空格全选>",
UseSelect: true,
AllowNone: true,
@ -19,11 +19,11 @@ export class FindMaxOrMinSizeBoard implements Command
let selectBoards: Board[] = [];
if (enRes.Status === PromptStatus.OK)
if (ssRes.Status === PromptStatus.OK)
{
selectBoards = enRes.SelectSet.SelectEntityList as Board[];
selectBoards = ssRes.SelectSet.SelectEntityList as Board[];
}
else if (enRes.Status === PromptStatus.None)
else if (ssRes.Status === PromptStatus.Other)
{
selectBoards = app.Database.ModelSpace.Entitys.filter(e => e instanceof Board) as Board[];
}

@ -37,7 +37,7 @@ export class DrawAlignedDimension implements Command
]
});
if (ptRes.Status === PromptStatus.String)
if (ptRes.Status === PromptStatus.Keyword)
{
this._UseFirstPointUCS = !this._UseFirstPointUCS;
continue;

@ -51,9 +51,10 @@ export class Command_Extend implements Command
Callback: (entss) => { this.DynmicExtend(entss, exRefCus); }
});
if (exSs.Status !== PromptStatus.OK)
if (exSs.Status === PromptStatus.OK)
this.Extend(exSs.SelectSet, exRefCus, false);
else if (exSs.Status === PromptStatus.Cancel || exSs.Status === PromptStatus.Other)
break;
this.Extend(exSs.SelectSet, exRefCus, false);
}
}

@ -101,6 +101,8 @@ export class CommandFillet implements Command
{
enRes2 = await app.Editor.GetEntity({
Msg: "选择第二个对象,或按住shift键选择对象以应用角点或输入半径:",
AllowAnyString: true,
NotNone: true,
Filter: {
filterTypes: [Curve, RoomWallBase],
filterErase: true,
@ -122,7 +124,7 @@ export class CommandFillet implements Command
if (!isNaN(rad))
this.UpdateFilletRadius(rad);
}
else if (enRes2.Status !== PromptStatus.None)
else
break;
}
app.Editor.UCSMatrix = oldUcs;
@ -216,6 +218,8 @@ export class CommandFillet implements Command
let enRes = await app.Editor.GetEntity({
Msg: `选择第一个对象<R:${FixedNotZero(this._FilletRadius, 3)}>:`,
KeyWordList: keyword,
AllowAnyString: true,
NotNone: true,
Filter: {
filterTypes: [Curve, Board, RoomWallBase],
filterFunction: (o, en) =>
@ -245,8 +249,6 @@ export class CommandFillet implements Command
else
return enRes;
}
case PromptStatus.Cancel:
return;
case PromptStatus.Keyword:
if (enRes.StringResult === "R")
{
@ -275,6 +277,7 @@ export class CommandFillet implements Command
enRes = await app.Editor.GetEntity({
Msg: "请选择二维多段线或输入半径:",
Filter: { filterTypes: [Polyline] },
AllowAnyString: true,
Callback: (e) =>
{
if (e && e.Entity === lastPl)

@ -0,0 +1,54 @@
import { app } from "../ApplicationServices/Application";
import { EntitysUpdateWrap } from "../Common/EntityUpdateWrap";
import { Entity } from "../DatabaseServices/Entity/Entity";
import { Command } from "../Editor/CommandMachine";
import { PromptStatus } from "../Editor/PromptResult";
interface MatchProp
{
color: number;
}
export class Command_MatchProp implements Command
{
async exec()
{
let enRes = await app.Editor.GetEntity({
Msg: "请选择源实体",
NotNone: true,
Filter: { filterTypes: [Entity] }
});
if (enRes.Status !== PromptStatus.OK) return;
while (true)
{
let ssRes = await app.Editor.GetSelection({
Once: true,
AllowNone: true,
Msg: "选择需要修改的实体",
Filter: { filterTypes: [Entity] },
});
if (ssRes.Status === PromptStatus.Other || ssRes.Status === PromptStatus.Cancel)
return;
if (ssRes.Status !== PromptStatus.OK) continue;
let matchProp: MatchProp = {
color: 7
};
matchProp.color = enRes.Entity.ColorIndex;
let ents = ssRes.SelectSet.SelectEntityList as Entity[];
EntitysUpdateWrap(ents, () =>
{
for (let ent of ents)
{
ent.ColorIndex = matchProp.color;
}
});
}
}
}

@ -19,7 +19,7 @@ export class Command_M0 implements Command
let ssRes = await app.Editor.GetSelection({ UseSelect: true, Msg: "选择实体<空格选择全部>:", AllowNone: true });
if (ssRes.Status === PromptStatus.Cancel) return;
let ents: Entity[];
if (ssRes.Status === PromptStatus.None)
if (ssRes.Status === PromptStatus.Other)
ents = app.Database.ModelSpace.Entitys.filter(e => !e.IsErase);
else
ents = ssRes.SelectSet.SelectEntityList;

@ -78,7 +78,7 @@ export class Command_Trim implements Command
// for (let c of kniefCus)
// c.RestoreJigMaterial();
if (trSsRes.Status === PromptStatus.Cancel || trSsRes.Status === PromptStatus.None)
if (trSsRes.Status === PromptStatus.Cancel || trSsRes.Status === PromptStatus.Other)
break;
if (!trSsRes.SelectSet)
continue;

@ -130,7 +130,7 @@ export class OneKeyLayout implements Command
let gRes = await app.Editor.GetEntity({
Msg: `选择一键布局的图框<当前出图方式[${composeMap.get(groupType)[0]}]>:`,
KeyWordList: keyWordList.concat(keyword),
// NotNone: true,
NotNone: true,
Filter: {
filterFunction: (o, e) => e?.GroupId?.Object !== undefined
}
@ -200,15 +200,6 @@ export class OneKeyLayout implements Command
break;
}
}
else if (gRes.Status === PromptStatus.None)
{
AppToaster.show({
message: "未选择图框或选择的图框未编组!",
timeout: 3000,
intent: Intent.WARNING
});
return;
}
else return;
}

@ -248,6 +248,7 @@ export enum CommandNames
CheckHoles = "CHECKHOLES",
CombinatAttributeBrush = "COMBINATATTRIBUTEBRUSH",//复合实体刷
MatchProp = "MATCHPROP",//特性属性刷
Rect2Winerack = "RECT2WINERACK",//矩形变酒格
EditView = "EDITVIEW", //编辑视口
EditFrame = "EDITFRAME", //编辑图框

@ -150,6 +150,7 @@ import { Command_Lisp } from "../Add-on/Lisp";
import { DownLoadDConfig, DownloadHoleOption, UpLoadConfig, UploadHoleOption } from "../Add-on/LoadConfig";
import { Fbx } from "../Add-on/loadfbx";
import { LookOverBoardInfos } from "../Add-on/LookOverBoardInfos/LookOverBoardInfos";
import { Command_MatchProp } from "../Add-on/MatchProp";
import { MirrorCommand } from "../Add-on/Mirror";
import { Command_Move } from "../Add-on/Move";
import { Command_Cmd_Down } from "../Add-on/Move/Cmd_Down";
@ -727,6 +728,8 @@ export function registerCommand()
commandMachine.RegisterCommand(CommandNames.CheckHoles, new CheckHoles());
commandMachine.RegisterCommand(CommandNames.CombinatAttributeBrush, new CombinatAttributeBrush());
commandMachine.RegisterCommand(CommandNames.MatchProp, new Command_MatchProp());
commandMachine.RegisterCommand(CommandNames.Rect2Winerack, new Polyline2Winerack());

@ -160,10 +160,11 @@ export class GetEntityServices implements EditorService
this._Return({ Status: PromptStatus.String, StringResult: input });
else
{
if (prompt.NotNone)
this._Editor.Prompt("禁止空选择!");
else
this._Return({ Status: PromptStatus.Other });
//我们把空格定义为取消,所以应该允许空格 或者右键的时候
// if (prompt.NotNone)
// this._Editor.Prompt("禁止空选择!");
// else
this._Return({ Status: PromptStatus.Other });
}
}));
}

@ -114,7 +114,7 @@ export class SsgetServiecs
{
if (prompt.AllowNone || this.HasSelection(set))
{
this.ReturnOk(true);
this.ReturnOk(true, true);
return;
}
this._Editor.Prompt("禁止空选择!");
@ -190,12 +190,15 @@ export class SsgetServiecs
return set.SelectEntityList.length > 0;
}
private ReturnOk(check = false)
private ReturnOk(check = false, isOther = false)
{
let status = PromptStatus.OK;
if (check)
status = this._Editor.SelectCtrl.SelectSet.SelectSetList.length !== 0 ? PromptStatus.OK : PromptStatus.None;
this.Return({ Status: status, SelectSet: this._Editor.SelectCtrl.SelectSet });
status = this._Editor.SelectCtrl.SelectSet.SelectSetList.length !== 0 ? PromptStatus.OK : (isOther ? PromptStatus.Other : PromptStatus.None);
let res: PromptSsgetResult = { Status: status, SelectSet: this._Editor.SelectCtrl.SelectSet };
this.Return(res);
}
//返回取消状态

@ -74,6 +74,7 @@ export interface GetEntityPrompt extends PromptOptions
UseSelect?: boolean; //使用当前已经选中的实体.
IsSelect?: boolean;
Filter?: Filter;
AllowAnyString?: boolean;//允许任何字符串输入
Callback?: (res: PromptEntityResult) => void;
}

@ -3,13 +3,16 @@ import { Entity } from '../DatabaseServices/Entity/Entity';
import { ObjectSnapMode } from './ObjectSnapMode';
import { SelectSet } from './SelectSet';
//当前仅在GetEntity 和Ssget上严格实现了 None 和 Other的情况
//其他的只有None 没有Other(其他的也不可能出现想选没选到的情况)
export enum PromptStatus
{
None = 0,
None = 0, //用户想选,但是没选到(手滑了 没点到)
Cancel = -1,
OK = 1,
Keyword = 2,
Other = 4,
Other = 4,//用户不想选了,直接拍桌子要求上菜 GetEntity(右键 右键<确认> 空格)
String = 8,
Error = -2
}

@ -784,6 +784,16 @@ export const CommandList: ICommand[] = [
chName: "恢复板件颜色",
chDes: "恢复板件颜色",
},
{
icon: IconEnum.Cabrush,
typeId: "bjbj",
link: `#`,
defaultCustom: "MA",
command: CommandNames.MatchProp,
type: "板件编辑",
chName: "特性匹配",
chDes: "特性属性刷(目前支持颜色属性)",
},
{
icon: IconEnum.Cabrush,
typeId: "bjbj",
@ -1795,6 +1805,39 @@ export const CommandList: ICommand[] = [
// enName: "Join",
chDes: "合并线性和弯曲对象的端点,以便创建单个对象",
},
{
icon: IconEnum.RegionUnion,
typeId: "i2dbj",
link: `#`,
defaultCustom: "INT",
command: CommandNames.Intersect,
type: "二维编辑",
chName: "面域并集",
// enName: "Region Intersect",
chDes: "面域并集",
},
{
icon: IconEnum.RegionIntersect,
typeId: "i2dbj",
link: `#`,
defaultCustom: "UNION",
command: CommandNames.Union,
type: "二维编辑",
chName: "面域交集",
// enName: "Region Union",
chDes: "面域交集",
},
{
icon: IconEnum.RegionSub,
typeId: "i2dbj",
link: `#`,
defaultCustom: "SUB",
command: CommandNames.Substract,
type: "二维编辑",
chName: "面域差集",
// enName: "Region Sub",
chDes: "面域差集",
},
//#endregion
//#region 其他命令
@ -1919,16 +1962,6 @@ export const CommandList: ICommand[] = [
// enName: "Break",
chDes: "在两点之间打断选定对象",
},
{
typeId: "util",
link: `#`,
defaultCustom: "TOGGLEUI",
command: CommandNames.ToggleUI,
type: "工具",
chName: "隐藏顶部工具栏",
// enName: "Join",
chDes: "隐藏顶部工具栏",
},
// {
// icon: IconEnum.FBX,
// typeId: "util",
@ -2002,39 +2035,6 @@ export const CommandList: ICommand[] = [
chName: "显示所有",
chDes: "显示所有",
},
{
icon: IconEnum.RegionUnion,
typeId: "util",
link: `#`,
defaultCustom: "INT",
command: CommandNames.Intersect,
type: "工具",
chName: "面域并集",
// enName: "Region Intersect",
chDes: "面域并集",
},
{
icon: IconEnum.RegionIntersect,
typeId: "util",
link: `#`,
defaultCustom: "UNION",
command: CommandNames.Union,
type: "工具",
chName: "面域交集",
// enName: "Region Union",
chDes: "面域交集",
},
{
icon: IconEnum.RegionSub,
typeId: "util",
link: `#`,
defaultCustom: "SUB",
command: CommandNames.Substract,
type: "工具",
chName: "差集",
// enName: "Region Sub",
chDes: "差集",
},
{
icon: IconEnum.Sweep,
typeId: "util",
@ -2104,7 +2104,7 @@ export const CommandList: ICommand[] = [
command: CommandNames.M0,
type: "工具",
chName: "移动到0点",
chDes: "移动到0点",
chDes: "移动到0点,并以指定间距(在配置中设置)排开",
},
{
typeId: "util",
@ -2684,17 +2684,26 @@ export const CommandList: ICommand[] = [
defaultCustom: "COMANP",
command: CommandNames.Comanp,
type: "内置",
chName: "命令面板与快捷键",
chDes: "系统命令",
chName: "命令与快捷键",
chDes: "搜索命令,设置自定义命令,设置快捷键,查看命令帮助",
systemHotkeys: HotkeyList.F1,
},
{
typeId: "",
link: `#`,
defaultCustom: "TOGGLEUI",
command: CommandNames.ToggleUI,
type: "内置",
chName: "隐藏顶部工具栏",
chDes: "隐藏顶部工具栏",
},
{
typeId: "",
defaultCustom: "PROPERTIESBAR",
command: CommandNames.PropertiesBar,
type: "内置",
chName: "左侧特性栏",
chDes: "系统命令",
chName: "开关左侧特性栏",
chDes: "显示实体特性",
defaultHotkeys: HotkeyList.C1,
},
{
@ -2702,8 +2711,8 @@ export const CommandList: ICommand[] = [
defaultCustom: "MODULEBAR",
command: CommandNames.ModuleBar,
type: "内置",
chName: "右侧模块栏",
chDes: "系统命令",
chName: "开关右侧面板",
chDes: "开关右侧面板",
defaultHotkeys: HotkeyList.C2,
},
{
@ -2729,48 +2738,48 @@ export const CommandList: ICommand[] = [
defaultCustom: "RPZX",
command: CommandNames.RightPanelModel,
type: "内置",
chName: "显示造型面板",
chDes: "系统命令",
chName: "显示右侧面板(造型)",
chDes: "显示右侧面板(造型)",
},
{
typeId: "",
defaultCustom: "RP2D",
command: CommandNames.RightPanelModel2,
type: "内置",
chName: "显示二维刀路面板",
chDes: "系统命令",
chName: "显示右侧面板(二维刀路)",
chDes: "显示右侧面板(二维刀路)",
},
{
typeId: "",
defaultCustom: "RP3D",
command: CommandNames.RightPanelModel3,
type: "内置",
chName: "显示三维刀路面板",
chDes: "系统命令",
chName: "显示右侧面板(三维刀路)",
chDes: "显示右侧面板(三维刀路)",
},
{
typeId: "",
defaultCustom: "RPS",
command: CommandNames.RightPanelScene,
type: "内置",
chName: "显示场景面板",
chDes: "系统命令",
chName: "显示右侧面板(场景)",
chDes: "显示右侧面板(场景)",
},
{
typeId: "",
defaultCustom: "RPM",
command: CommandNames.RightPanelMaterial,
type: "内置",
chName: "显示材质面板",
chDes: "系统命令",
chName: "显示右侧面板(材质)",
chDes: "显示右侧面板(材质)",
},
{
typeId: "",
defaultCustom: "RIGHTPANEL",
command: CommandNames.RightPanelTemplateParam,
type: "内置",
chName: "显示模块参数面板",
chDes: "系统命令",
chName: "显示右侧面板(模块参数)",
chDes: "显示右侧面板(模块参数)",
defaultHotkeys: HotkeyList.CM,
},
{
@ -2778,16 +2787,16 @@ export const CommandList: ICommand[] = [
defaultCustom: "RPWJ",
command: CommandNames.RightPanelMetals,
type: "内置",
chName: "显示五金面板",
chDes: "系统命令",
chName: "显示右侧面板(五金)",
chDes: "显示右侧面板(五金)",
},
{
typeId: "",
defaultCustom: "RPMX",
command: CommandNames.RightPanelModule,
type: "内置",
chName: "显示模型",
chDes: "系统命令",
chName: "显示右侧面板(模型)",
chDes: "显示右侧面板(模型)",
},
{
typeId: "",
@ -2795,7 +2804,7 @@ export const CommandList: ICommand[] = [
onlyHasHotkeys: true,
type: "内置",
chName: "命令强制结束",
chDes: "系统命令",
chDes: "有时候命令无法结束,这个时候可以使用这个快捷键强制结束.",
systemHotkeys: HotkeyList.CAE,
},
];

@ -78,6 +78,7 @@ export class TopToolBar extends React.Component<{}, {}>
{ svg: IconEnum.UpdateInfo, title: "根据板名修改属性", command: CommandNames.UpdateBoardInfos },
{ svg: IconEnum.ChangeColorByMat, title: "根据板材修改颜色", command: CommandNames.ChangeColorByMaterial },
{ svg: IconEnum.RestoreColor, title: "恢复板件颜色", command: CommandNames.RestoreColor },
{ svg: IconEnum.Cabrush, title: "特性匹配", command: CommandNames.MatchProp },
{ svg: IconEnum.Cabrush, title: "复合实体属性刷", command: CommandNames.CombinatAttributeBrush },
{ svg: IconEnum.Rect2Winerack, title: "矩形变酒格", command: CommandNames.Rect2Winerack },
];

Loading…
Cancel
Save