www.mxdraw.com
内容索引主面
前一个向上下一个
MxDrawXCustomFunction::ExApp_SelectEntityForVierport 方法

由一个点得到视口中的对象实体。

IDL
static BOOL ExApp_SelectEntityForVierport(McGePoint3d pt, OUT AcDbObjectIdArray& aryId);

例如: C#

private void axMxDrawX1_MouseEvent(object sender, AxMxDrawXLib._DMxDrawXEvents_MouseEventEvent e)
    {
        //  "lType 是事件类型,1鼠标移动,2是鼠标左键按下,3是鼠标右键按下,4是鼠标左键双击.lRet 返回非0,消息将不在往下传递"
        if(e.lType == 4)
        {
            MxDrawResbuf ret = (MxDrawResbuf)axMxDrawX1.Call("Mx_IsRuningCommand", "");
            if ((ret.AtString(0) == "Ok")
                && ret.AtString(1) != "intellisel"
                )
                return;

            // 鼠标左键双击.
            // 构建选择集,找到鼠标左建双击下的实体。

            MxDrawSelectionSet ss = new MxDrawSelectionSet();
            MxDrawResbuf filter = new MxDrawResbuf();
            //filter.AddString("LINE",5020);
            MxDrawPoint point = new MxDrawPoint();
            point.x = e.dX;
            point.y = e.dY;
            ss.SelectAtPoint2(point,filter);
            if(ss.Count > 0)
            {
                MxDrawEntity ent = ss.Item(0);
                MessageBox.Show("点击了" + ent.ObjectName + "对象");
                /*
                if (ent is MxDrawLine)
                {
                    MxDrawLine line = (MxDrawLine)ent;
                }
                 */
            }
            else
            {
                // 视口中有没有实体被点击.
                MxDrawResbuf param = new MxDrawResbuf();
                param.AddPoint(point,-10);
                MxDrawResbuf ret2 = (MxDrawResbuf)axMxDrawX1.CallEx("ExApp_SelectEntityForVierport", param);
                if (ret2.AtString(0) == "Ok")
                {
                    Int32 lId = ret2.AtLong(1);
                    MxDrawDatabase database = (MxDrawDatabase)axMxDrawX1.GetDatabase();
                    MxDrawEntity ent = (MxDrawEntity)database.ObjectIdToObject(lId);

                    MessageBox.Show("点击了" + ent.ObjectName + "对象");


                }

            }
            e.lRet = 1;
            // 取消后面的命令。
            axMxDrawX1.SendStringToExecute("");
        }
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!