在进行块参照拖拽即时绘图时有时会出现如下错误?
错误行代码如下:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.GraphicsInterface;
namespace 标准化单机版
{
publicclass EntJip:DrawJig
{
public Entity m_blo;
//public BlockReference m_blo;
private Point3d m_pt1, m_pt2;
private double rotate;
private double scale;
public EntJip(Point3d pt1,BlockReference blo,double sc)
{
m_pt1 = pt1;//块的插入点
m_blo = blo as Entity;
rotate = 0;
scale = sc;
}
protected override bool WorldDraw(WorldDraw draw)
{
draw.Geometry.Draw(m_blo);
return false;
}
protected override SamplerStatus Sampler(JigPrompts prompts)
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Matrix3d mt = ed.CurrentUserCoordinateSystem;
JigPromptPointOptions optJigPoint = new JigPromptPointOptions("\n请指定第二点:");
optJigPoint.Cursor = CursorType.NoSpecialCursor;
optJigPoint.UserInputControls = UserInputControls.Accept3dCoordinates
| UserInputControls.NoZeroResponseAccepted
| UserInputControls.NoNegativeResponseAccepted;
optJigPoint.BasePoint = m_pt1.TransformBy(mt);//基点必须是WCS点
optJigPoint.UseBasePoint = true;
//获得点
//try
//{
PromptPointResult resJigPoint = prompts.AcquirePoint(optJigPoint);//错误信息中说在这行出错
m_pt2 = resJigPoint.Value;
if (resJigPoint.Status != PromptStatus.OK) return SamplerStatus.Cancel;
Point3d ucsPt = m_pt2.TransformBy(mt.Inverse());
double temprotate = ucsPt.AngleFromXAxis(m_pt1);
//拖拽取消
if (resJigPoint.Status == PromptStatus.Cancel)
{
return SamplerStatus.Cancel;
}
//进行拖拽
if (rotate != temprotate)
{
double rotateangle = temprotate - rotate;
rotate = temprotate;
m_blo.TransformBy(Matrix3d.Scaling(scale, m_pt1.TransformBy(mt)) * Matrix3d.Rotation(rotateangle, Vector3d.ZAxis, m_pt1.TransformBy(mt)));
return SamplerStatus.OK;
}
else
{
return SamplerStatus.NoChange;
}
//}
//catch (Exception ex)
//{
// Application.ShowAlertDialog(ex.Message);
// return SamplerStatus.NoChange;
//}
}
}
}
还请高手抽时间给分析一下! 多谢
页:
[1]