diff --git a/src/Add-on/Stretch.ts b/src/Add-on/Stretch.ts index f0feecf22..431cf7af5 100644 --- a/src/Add-on/Stretch.ts +++ b/src/Add-on/Stretch.ts @@ -1,4 +1,4 @@ -import { Matrix4, Vector3 } from 'three'; +import { Matrix4, Object3D, Vector3 } from 'three'; import { app } from '../ApplicationServices/Application'; import { StretchData, StretchParse } from '../Common/StretchParse'; import { Command } from '../Editor/CommandMachine'; @@ -8,9 +8,36 @@ import { PromptStatus } from '../Editor/PromptResult'; export class Stretch implements Command { + constructor(private useSelectFilter = false) + { + } async exec() { - let ssRes = await app.Editor.GetSelection({ UseSelect: true, Msg: "请选择拉伸对象:" }); + let filterEntitySet: Set; + if (this.useSelectFilter) + { + let filterRes = await app.Editor.GetSelection({ UseSelect: true, Msg: "请选择要被拉伸的对象:", AllowNone: true }); + if (filterRes.Status === PromptStatus.Cancel) + return; + + if (filterRes.Status === PromptStatus.OK) + { + filterEntitySet = new Set(); + for (let e of filterRes.SelectSet.SelectObjectList) + filterEntitySet.add(e); + } + } + + let ssRes = await app.Editor.GetSelection({ + UseSelect: true, Msg: "请选择拉伸对象:", Filter: { + filterFunction: (obj, ent) => + { + if (filterEntitySet) + return filterEntitySet.has(obj); + return true; + } + } + }); if (ssRes.Status !== PromptStatus.OK) return; let p1 = await app.Editor.GetPoint({ Msg: "指定基点:", NotSnapZ: true });//, KeyWordList: [{ msg: "位移", key: "D" }] diff --git a/src/Add-on/ssget.ts b/src/Add-on/ssget.ts deleted file mode 100644 index 3b21d6b01..000000000 --- a/src/Add-on/ssget.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { app } from '../ApplicationServices/Application'; -import { Command } from '../Editor/CommandMachine'; -import { PromptStatus } from '../Editor/PromptResult'; - -export class Command_Ssget implements Command -{ - constructor() - { - - } - async exec() - { - let ss = await app.Editor.GetSelection(); - if (ss.Status === PromptStatus.OK) - { - for (let en of ss.SelectSet.SelectEntityList) - { - en.ColorIndex = 1; - } - } - } -} diff --git a/src/Editor/CommandRegister.ts b/src/Editor/CommandRegister.ts index d20ddb3b9..03bccfd58 100644 --- a/src/Editor/CommandRegister.ts +++ b/src/Editor/CommandRegister.ts @@ -106,7 +106,6 @@ import { Command_Rotate } from "../Add-on/Rotate"; import { RotateLayerBoard } from "../Add-on/RotateLayerBoard"; import { New, Save, SaveAs, SaveAsBinary } from "../Add-on/Save"; import { Command_Scale } from "../Add-on/Scale"; -import { Command_Ssget } from "../Add-on/ssget"; import { Stretch } from "../Add-on/Stretch"; import { Sweep } from "../Add-on/Sweep"; import { Command_SwitchCamera } from "../Add-on/SwitchCamera"; @@ -184,7 +183,8 @@ export function registerCommand() commandMachine.RegisterCommand("testPointParse", new Command_TestPointPickParse()); - commandMachine.RegisterCommand("s", new Stretch()); + commandMachine.RegisterCommand("Stretch", new Stretch()); + commandMachine.RegisterCommand("SelectStretch", new Stretch(true)); commandMachine.RegisterCommand("fs", new ViewChange(new Vector3(0, 0, -1))); commandMachine.RegisterCommand("qs", new ViewChange(new Vector3(0, 1))); @@ -232,8 +232,6 @@ export function registerCommand() commandMachine.RegisterCommand("tr", new Command_Trim()); - commandMachine.RegisterCommand("ss", new Command_Ssget()); - commandMachine.RegisterCommand("f", new CommandFillet()); commandMachine.RegisterCommand("testFilletCode", new TestFillet()); diff --git a/src/UI/Components/CommandPanel/CommandList.ts b/src/UI/Components/CommandPanel/CommandList.ts index 9d93b5c75..a3c3c9d03 100644 --- a/src/UI/Components/CommandPanel/CommandList.ts +++ b/src/UI/Components/CommandPanel/CommandList.ts @@ -980,11 +980,22 @@ export const CommandList: ICommand[] = observable([ typeId: "util", link: "#", defaultCustom: "S", - command: "S", + command: "STRETCH", type: "工具", chName: "拉伸", // enName: "Stretch", - chDes: "拉伸与选择窗口或多边形交叉的对象", + chDes: "拉伸与选择窗口或多边形交叉的对象.", + }, + { + icon: IconEnum.Stretch, + typeId: "util", + link: "#", + defaultCustom: "SS", + command: "SELECTSTRETCH", + type: "工具", + chName: "选择拉伸", + // enName: "Stretch", + chDes: "先选择要拉伸的对象,在选择拉伸范围拉伸.", }, { icon: IconEnum.GridStretch,