zhengjian211 发表于 2011-10-30 17:51:30

com下获取屏幕点取的点

private void 获取对象名称_Click(object sender, EventArgs e)
{
Microsoft.VisualBasic.Interaction.AppActivate(AcadApp.Caption);
object returnObj,pickPoint;
string pickPrompt = "选取物体对象!";
double[] pickPointArray;
AcadDoc.Utility.GetEntity(out returnObj, out pickPoint, pickPrompt);
AcadObject returnCADObj = (AcadObject)returnObj;
pickPointArray =(Double[])pickPoint;
MessageBox.Show("选取对象为:" + returnCADObj.ObjectName.ToString());
MessageBox.Show("点击位置:X=" + pickPointArray.ToString() + ",Y=" +
pickPointArray.ToString() + ",Z=" + pickPointArray.ToString());
Microsoft.VisualBasic.Interaction.AppActivate(this.Text);
}

书上的方法是这样的 但是当在屏幕空白处点击孤立点时就报错,请问如何获取屏幕空白处点选的点的坐标?

zhengjian211 发表于 2011-10-30 18:37:37

已经解决
object nullpt = Type.Missing;   
            pickPointArray=(double[]) AcadDoc.Utility.GetPoint( nullpt,"选择点");

sailorcwx 发表于 2011-10-31 10:18:52

可以用try catch来捕捉错误吧
页: [1]
查看完整版本: com下获取屏幕点取的点