|
|
|
@ -8,6 +8,7 @@ import { JigUtils } from '../Editor/JigUtils';
|
|
|
|
|
import { ObjectSnapMode } from '../Editor/ObjectSnapMode';
|
|
|
|
|
import { PromptStatus } from '../Editor/PromptResult';
|
|
|
|
|
import { SelectPick } from '../Editor/SelectPick';
|
|
|
|
|
import { equalv3, ZeroVec } from '../Geometry/GeUtils';
|
|
|
|
|
|
|
|
|
|
export class DrawLine implements Command
|
|
|
|
|
{
|
|
|
|
@ -107,3 +108,39 @@ export class DrawLine implements Command
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class Command_DrawXLine implements Command
|
|
|
|
|
{
|
|
|
|
|
async exec()
|
|
|
|
|
{
|
|
|
|
|
let ptRes = await app.Editor.GetPoint({ Msg: "请输入第一个点:" });
|
|
|
|
|
if (ptRes.Status !== PromptStatus.OK)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
let p1 = ptRes.Point;
|
|
|
|
|
let line = new Line();
|
|
|
|
|
JigUtils.Draw(line);
|
|
|
|
|
|
|
|
|
|
const UpdateLine = (p2: Vector3) =>
|
|
|
|
|
{
|
|
|
|
|
let normal = p2.clone().sub(p1);
|
|
|
|
|
if (equalv3(normal, ZeroVec, 1e-2)) return;
|
|
|
|
|
|
|
|
|
|
normal.normalize().multiplyScalar(4000);
|
|
|
|
|
let p3 = p1.clone().add(normal);
|
|
|
|
|
let p4 = p1.clone().sub(normal);
|
|
|
|
|
line.StartPoint = p3;
|
|
|
|
|
line.EndPoint = p4;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let pt2Res = await app.Editor.GetPoint({
|
|
|
|
|
BasePoint: p1,
|
|
|
|
|
Msg: "输入方向:", Callback: UpdateLine
|
|
|
|
|
});
|
|
|
|
|
if (pt2Res.Status !== PromptStatus.OK)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
UpdateLine(pt2Res.Point);
|
|
|
|
|
app.Database.ModelSpace.Append(line);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|