You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/src/Add-on/Command_SetBRXAxis.ts

38 lines
1.2 KiB

import { app } from "../ApplicationServices/Application";
import { Board } from "../DatabaseServices/Entity/Board";
import { Command } from "../Editor/CommandMachine";
import { PromptStatus } from "../Editor/PromptResult";
import { HotCMD } from "../Hot/HotCommand";
@HotCMD
export class Command_SetBRXAxis implements Command
{
async exec()
{
app.Editor.Prompt("命令:设置拉伸实体的X轴指向.");
let enRes = await app.Editor.GetEntity({ Filter: { filterTypes: [Board] } });
if (enRes.Status !== PromptStatus.OK) return;
let br = enRes.Entity as Board;
let oldUCS = app.Editor.UCSMatrix.clone();
app.Editor.UCSMatrix = br.OCS;
let baseRes = await app.Editor.GetPoint({ Msg: "点击轴线起点:" });
if (baseRes.Status !== PromptStatus.OK)
{
app.Editor.UCSMatrix = oldUCS;
return;
}
let pres = await app.Editor.GetPoint({ Msg: "点击轴线终点:" });
if (pres.Status !== PromptStatus.OK)
{
app.Editor.UCSMatrix = oldUCS;
return;
}
br.SetXAxis(pres.Point.sub(baseRes.Point));
app.Editor.UCSMatrix = oldUCS;
}
}