乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 34|回复: 0

鼠标拉框事件问题

[复制链接]
LDJ

20

主题

35

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
115
发表于 2015-7-22 09:16:00 | 显示全部楼层 |阅读模式
鼠标拉框后  1 绘制出这个框
2 不让entity被选中
下面代码有异常,框没有绘制出来,另外 2 没有解决
全局变量   Point3d startPt;
    Autodesk..ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.PromptingForCorner += new PromptPointOptionsEventHandler(Editor_PromptingForCorner);
            Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.PromptedForCorner += new PromptPointResultEventHandler(Editor_PromptedForCorner);
   void Editor_PromptingForCorner(object sender, PromptPointOptionsEventArgs e)
        {
            startPt = e.Options.BasePoint;
        }
  void Editor_PromptedForCorner(object sender, PromptPointResultEventArgs e)
        {
            Point3d endPt = e.Result.Value;
            Editor ed=Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            //Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(startPt.X.ToString() + ":" + startPt.Y.ToString() + ":" + endPt.X.ToString());
            //PromptSelectionResult res = ed.SelectImplied();
            //if (res.Status != PromptStatus.OK) return;
            //if (res.Value.Count == 0) return;
            //Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("d2d");
            Database db = ed.Document.Database;
            Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager;
            using (Transaction tr = tm.StartTransaction())
            {
               
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("d1d");
                BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForWrite);
                BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
                Polyline entity = new Polyline();
                //之前的代码出现异常
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("d2d");
                entity.AddVertexAt(entity.NumberOfVertices, new Point2d(startPt.X, startPt.Y), 0, -1, -1);
                entity.AddVertexAt(entity.NumberOfVertices, new Point2d(endPt.X, startPt.Y), 0, -1, -1);
                entity.AddVertexAt(entity.NumberOfVertices, new Point2d(endPt.X, endPt.Y), 0, -1, -1);
                entity.AddVertexAt(entity.NumberOfVertices, new Point2d(startPt.X, endPt.Y), 0, -1, -1);
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("d3d");
                entity.Closed = true;
                entity.ColorIndex = 1;
                entity.LineWeight = LineWeight.LineWeight005;
                //entity.Layer = layername;// layer.Name;
                btr.AppendEntity(entity);
                tr.AddNewlyCreatedDBObject(entity, true);
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("d4d");
                //for (int i = 0; i < res.Value.Count; i++)
                //{
                //    Entity entity = tr.GetObject(res.Value[i].ObjectId, OpenMode.ForWrite) as Entity;
                //    entity.Unhighlight();
                //    Autodesk.AutoCAD.ApplicationServices.Application.UpdateScreen();
                //}
                tr.Commit();
            }
           
        }
各位大神,帮助看下。谢谢
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 11:20 , Processed in 0.603552 second(s), 65 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表