59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Bricscad.EditorInput;
|
|
using Teigha.DatabaseServices;
|
|
using Teigha.Geometry;
|
|
using Teigha.GraphicsInterface;
|
|
|
|
namespace SWS.CAD.CADFunc
|
|
{
|
|
// 自定义Jig类
|
|
public class BlockDragJig : DrawJig
|
|
{
|
|
private BlockReference _br;
|
|
private Bricscad.EditorInput.Editor _ed;
|
|
private Point3d _insertPoint;
|
|
|
|
public BlockDragJig(BlockReference br, Bricscad.EditorInput.Editor ed)
|
|
{
|
|
_br = br;
|
|
_ed = ed;
|
|
}
|
|
|
|
// 实时更新位置
|
|
protected override bool WorldDraw(WorldDraw draw)
|
|
{
|
|
draw.Geometry.Draw(_br);
|
|
return true;
|
|
}
|
|
|
|
// 处理鼠标移动
|
|
protected override SamplerStatus Sampler(JigPrompts prompts)
|
|
{
|
|
JigPromptPointOptions ppo = new JigPromptPointOptions("\n指定图元位置: ");
|
|
ppo.UserInputControls = UserInputControls.Accept3dCoordinates |
|
|
UserInputControls.NoZeroResponseAccepted |
|
|
UserInputControls.NoNegativeResponseAccepted;
|
|
|
|
PromptPointResult ppr = prompts.AcquirePoint(ppo);
|
|
|
|
if (ppr.Value != _insertPoint)
|
|
{
|
|
_insertPoint = ppr.Value;
|
|
_br.Position = _insertPoint;
|
|
return SamplerStatus.OK;
|
|
}
|
|
else
|
|
{
|
|
return SamplerStatus.NoChange;
|
|
}
|
|
}
|
|
|
|
// 获取最终插入点
|
|
public Point3d InsertPoint => _insertPoint;
|
|
}
|
|
}
|