zoukankan      html  css  js  c++  java
  • AUTOCAD二次开发-----删除一个图层里面的所有对象

    https://blog.csdn.net/aasswwe/article/details/40899759

    private void Test()
            {
                // 获取当前文档和数据库
                Document acDoc = Application.DocumentManager.MdiActiveDocument;
                Database acCurDb = acDoc.Database;
                Editor ed = acDoc.Editor;
    
                //启动事务
                using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
                {
                    //使用选择过滤器定义选择集规则
                    TypedValue[] typedValue = new TypedValue[1];
                    //TestLayer为图层名字 DxfCode.LayerName为筛选类型   详情见下面的DXF组码
                    typedValue.SetValue(new TypedValue((int)DxfCode.LayerName, "TestLayer"), 0);
                    SelectionFilter filter = new SelectionFilter(typedValue);
    
                    //根据条件 选择当前空间内所有未锁定及未冻结的对象。
                    //从图形中选择对象有几种方式,详情见下表
                    PromptSelectionResult result = ed.SelectAll(filter);
    
                    // 如果提示状态OK,表示已选择到对象 反之则没有对象
                    if (result.Status != PromptStatus.OK) { return; }
    
                    SelectionSet acSSet = result.Value;
    
                    // 遍历选择集内的对象
                    foreach (ObjectId id in acSSet.GetObjectIds())
                    {
                        Entity hatchobj = acTrans.GetObject(id, OpenMode.ForWrite) as Entity;
                        hatchobj.Erase();//删除
                    }
                    acTrans.Commit();
                }
            }
  • 相关阅读:
    阿里云ECS网站备案流程
    python学习之os.walk()
    python学习之pypandoc
    linux下的which
    python学习之range()和xrange()
    Python内置函数之repr()
    python学习之字典
    SQL基础之聚合与排序
    SQL基础教程
    lombok的安装
  • 原文地址:https://www.cnblogs.com/belx/p/9256326.html
Copyright © 2011-2022 走看看