Jig基点的问题
先看文字移动时的图片本帖最后由 xgr 于 2011-9-13 17:07 编辑
问题是为什么第一次的JIG基点不在文字角上,而第二次就真确了。
下面是JIG代码
#region CAD实体移动通用函数
public class CADJig
{
/// <summary>
///入口函数
/// </summary>
/// <param name="ed">ed</param>
/// <param name="lstEnt">实体列表</param>
/// <param name="promp">提示</param>
/// <returns></returns>
public static bool Jig(Editor ed, List<Entity> lstEnt, Point3d pt, string promp)
{
Jig jig = new Jig();
jig.lstEnt = lstEnt;
jig.ptBase = pt;
jig.promp = promp;
PromptResult prJig = ed.Drag(jig);
if (prJig.Status != PromptStatus.OK)
{
return false;
}
else
{
return true;
}
}
}
//本类是Jig,单独的实体或实体列表均可调用
public class Jig : DrawJig
{
private List<Entity> _lstEnt; //移动的实体
private Point3d _ptBase; //基点
private string _promp; //提示
/// <summary>
/// 移动的实体
/// </summary>
public List<Entity> lstEnt
{
set { _lstEnt = value; }
}
/// <summary>
/// 基点
/// </summary>
public Point3d ptBase
{
set { _ptBase = value; }
get { return _ptBase; }
}
/// <summary>
/// /提示
/// </summary>
public string promp
{
set { _promp = value; }
}
private Point3d ptTo; //插入点
protected override SamplerStatus Sampler(JigPrompts prompts)
{
JigPromptPointOptions optJigPoint = new JigPromptPointOptions(_promp);
optJigPoint.UserInputControls =
UserInputControls.Accept3dCoordinates |
UserInputControls.NoZeroResponseAccepted |
UserInputControls.NoNegativeResponseAccepted |
UserInputControls.NullResponseAccepted;
optJigPoint.Keywords.Add("Undo", "Undo", "放弃(U)");
PromptPointResult resJigPoint = prompts.AcquirePoint(optJigPoint);
Point3d curPt = resJigPoint.Value;
if (ptTo != curPt)
{
ptTo = curPt;
return SamplerStatus.OK;
}
else
{
ptBase = ptTo;
return SamplerStatus.NoChange;
}
}
protected override bool WorldDraw(WorldDraw draw)
{
try
{
Matrix3d mat = Matrix3d.Displacement(ptTo - ptBase);
foreach (Entity ent in _lstEnt)
{
//移动每个实体
ent.TransformBy(mat);
ent.RecordGraphicsModified(true);
draw.Geometry.Draw(ent);
}
}
catch (System.Exception)
{
return false;
}
return true;
}
}
#endregion
问下,你点击button的时候的鼠标点的左边怎么得到的?
这个是初始点,我没看到你是怎么将屏幕坐标转化为cad坐标的。 我估计自己的问题是点击按钮关闭窗口时,基点就是设置为这个点。
JIG是网上下载的。我套用了一下。
页:
[1]