码迷,mamicode.com
首页 > Web开发 > 详细

AutoCAD.Net 实现创建wipeout遮罩实体

时间:2018-12-12 00:23:47      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:record   遮罩   method   mdi   mode   rtt   block   dia   ica   

 [CommandMethod("mywipeout")]
        public static void mywipeout()
        {
            
            // 获取当前文档和数据库
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            // 启动事务
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // 以读模式打开Block表
                BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                OpenMode.ForRead) as BlockTable;
                // 以写模式打开Block表记录Model空间
                BlockTableRecord acBlkTblRec;
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                OpenMode.ForWrite) as BlockTableRecord;
                Point2dCollection pt2dArray = new Point2dCollection();
                pt2dArray.Add(new Point2d(0, 0));
                pt2dArray.Add(new Point2d(100, 0));
                pt2dArray.Add(new Point2d(100, 100));
                pt2dArray.Add(new Point2d(0, 100));
                pt2dArray.Add(new Point2d(0, 0));//必须闭合
                Wipeout wipeoutEnt = new Wipeout();
                wipeoutEnt.SetFrom(pt2dArray, new Vector3d(0, 0, 1));
                acBlkTblRec.AppendEntity(wipeoutEnt);
                acTrans.AddNewlyCreatedDBObject(wipeoutEnt, true);
                acTrans.Commit();
            }
        }

  

AutoCAD.Net 实现创建wipeout遮罩实体

标签:record   遮罩   method   mdi   mode   rtt   block   dia   ica   

原文地址:https://www.cnblogs.com/edata/p/10105336.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!