zoukankan      html  css  js  c++  java
  • 关闭所有有色斑的图层

    关闭所有有色斑的图层

    /*关闭所有有色斑的图层
     *
     * 色斑图层比较多的情况下,一个一个弄比较麻烦,这个一次全关,再配合图层状态保存功能就非常容易相互切换了
     *
     * http://goat.cublog.cn
     * 作者:王晓东 QQ:10516321 Email:xiaook@gmail.com
     *
     */

    using Autodesk.AutoCAD.ApplicationServices;
    using Autodesk.AutoCAD.DatabaseServices;
    using Autodesk.AutoCAD.EditorInput;
    using Autodesk.AutoCAD.Runtime;

    /*Copyright © CHINA 2009

    AutoCAD version:AutoCAD 2006
    Description:

    To use DelectObjectsInWindowPolyline.dll:

    1. Start AutoCAD and open a new drawing.
    2. Type netload and select CloseLayerHasHatchSolid.dll.
    3. Execute the xqd command.*/



    namespace CloseLayerHasHatchSolid
    {
        /// <summary>

        /// Summary for Class1.

        /// </summary>

        public class Class1
        {

            [CommandMethod("xcl")]
            public void xcl()
            {
                Document acDoc = Application.DocumentManager.MdiActiveDocument;
                Editor acDocEd = Application.DocumentManager.MdiActiveDocument.Editor;
                Database acDb = acDoc.Database;
                ObjectIdCollection acObjIdColl = new ObjectIdCollection();

                //选择范围线

                TypedValue[] tv = new TypedValue[2];
                tv[0] = new TypedValue((int)DxfCode.Start, "HATCH");
                tv[1] = new TypedValue((int)DxfCode.ShapeName, "SOLID");
                SelectionFilter sf = new SelectionFilter(tv);
                PromptSelectionResult acPtRes = acDocEd.SelectAll(sf);
                ObjectIdCollection oIdCol = new ObjectIdCollection();

                if (acPtRes.Status == PromptStatus.OK)
                {
                    SelectionSet ss = acPtRes.Value;
                    oIdCol = new ObjectIdCollection(ss.GetObjectIds());
                }
                foreach (ObjectId oid in oIdCol)
                {
                    using (Transaction acTrans = acDb.TransactionManager.StartTransaction())
                    {
                        Entity ent = (Entity)acTrans.GetObject(oid, OpenMode.ForRead);
                        LayerTable lt;
                        lt = (LayerTable)acTrans.GetObject(acDb.LayerTableId, OpenMode.ForRead);
                        LayerTableRecord ltr = (LayerTableRecord)acTrans.GetObject(lt[ent.Layer], OpenMode.ForWrite);
                        ltr.IsOff = true;
                        acTrans.Commit();
                    }
                }
            }
        }
    }

  • 相关阅读:
    将Python 程序打包成 .exe格式入门
    浅论各种调试接口(SWD、JTAG、Jlink、Ulink、STlink)的区别
    用pyinstaller打包python程序,解决打包时的错误:Cannot find existing PyQt5 plugin directories
    win10下 anaconda 环境下python2和python3版本转换
    zsh: command not found: conda的一种解决方法
    mac-os安装autojump
    六环外的商业
    浮躁的社会没错,错的是缺少一颗平静的心
    一张图看懂STM32芯片型号的命名规则
    OpenOCD的概念,安装和使用
  • 原文地址:https://www.cnblogs.com/gisoracle/p/2360258.html
Copyright © 2011-2022 走看看