AutoCAD.Net/C#.Net QQ群:193522571 删除编组(group) 尺寸线(dimension)

        public void deleteDimension()
        {
            //定义数据库
            Database db = HostApplicationServices.WorkingDatabase;
            //获取当前文件
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            //获取当前命令行对象
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                #region 删除组
                //定义组字典
                DBDictionary groupDict = (DBDictionary)db.GroupDictionaryId.GetObject(OpenMode.ForRead);
                //在组字典中搜索满足条件的组对象
                foreach (DictionaryEntry ide in groupDict)
                {
                    //获取组对象
                    acadGroup partGroup = (acadGroup)trans.GetObject((ObjectId)ide.Value, OpenMode.ForRead);
                    //对于组名包含"PART-"或匿名组中包含实体数量为2的组进行删除动作
                    if (partGroup.Name.Contains("PART-") || (partGroup.IsAnonymous && partGroup.NumEntities == 2))
                    {
                        //先删除组中的对象再删除组,直接删除组的话只是将组打散而已
                        foreach (ObjectId id in partGroup.GetAllEntityIds())
                        {
                            Entity ent = (Entity)id.GetObject(OpenMode.ForWrite);
                            ent.Erase();
                            ent.Dispose();
                        }
                        partGroup.UpgradeOpen();
                        partGroup.Erase(true);
                        partGroup.DowngradeOpen();
                    }
                }
                #endregion 删除组
                #region 删除尺寸线
                TypedValueList values = new TypedValueList();
                values.Add(0, typeof(Dimension).Name);
                SelectionFilter filter = new SelectionFilter(values);
                PromptSelectionResult psr = ed.SelectAll(filter);
                if (psr.Status == PromptStatus.OK)
                {
                    //Application.ShowAlertDialog(string.Format("被选中的尺寸线有{0}个!", psr.Value.Count));
                    foreach (ObjectId id in psr.Value.GetObjectIds())
                    {
                        Entity ent = (Dimension)id.GetObject(OpenMode.ForWrite);
                        ent.Erase();
                        ent.Dispose();
                    }
                }
                #endregion 删除尺寸线
                trans.Commit();
            }
        }

AutoCAD.Net/C#.Net QQ群:193522571 删除编组(group) 尺寸线(dimension)

时间: 2024-10-01 07:35:51

AutoCAD.Net/C#.Net QQ群:193522571 删除编组(group) 尺寸线(dimension)的相关文章

AutoCAD.Net/C#.Net QQ群:193522571 previewicon生成的块图标太小,CMLContentSearchPreviews生成大的图片

由于CMLContentSearchPreviews方法是AutoCAD2014中才加入的,所以只能应用于2014及以后版本,可惜啊! using System.IO; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime; using Autode

AutoCAD.Net/C#.Net QQ群:193522571 多个框架共一套代码在进行迁移时的问题,properties,resource,未能加载文件或程序集“System.Drawing, Version=4.0.0.0

此时在3.5框架工程中会出现 [未能加载文件或程序集“System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”或它的某一个依赖项.系统找不到指定的文件. 行 123,位置 5.] 的错误,解决办法是将4.0.0.0改成2.0.0.0.如下面的代码. 另外,在namespace进行了修改后需要将“原命名空间.properties.resource ”改成“现在的命名空间.properties

AutoCAD.Net/C#.Net QQ群:193522571 System.Drawing.Color和AutoDesk.AutoCAD.Colors.Color互转

假如各自实例化后的Color分别为: SysColor和CadColor 那么 SysColor转AutoDesk.AutoCAD.Colors.Color为:Autodesk.AutoCAD.Colors.Color.FromColor(SysColor) CadColor转 System.Drawing.Color为:CadColor.ColorValue

AutoCAD.Net/C#.Net QQ群:193522571 将DataTable集合 B加入到DataTable A中,应用于两个或以上的只有单行数据的无主键的datatable的合并 Merge

1 /// <summary> 2 /// 将DataTable集合 B加入到DataTable A中,应用于两个或以上的只有单行数据的无主键的datatable的合并 3 /// </summary> 4 /// <param name="ArrOrigeon">A</param> 5 /// <param name="ArrAdded">B</param> 6 /// <returns

AutoCAD.Net/C#.Net QQ群:193522571 resultbuffer 中的typedvalue

ResultBuffer中的TypedValue ,5005,5006,5009都代表什么类型? //运行命令 ResultBuffer rb = new ResultBuffer(); rb.Add(new TypedValue(5005, "_revcloud")); if (!cloudType) { rb.Add(new TypedValue(5005, "_s")); rb.Add(new TypedValue(5005, "_c"))

AutoCAD.Net/C#.Net QQ群:193522571 窗体不闪烁

public void MXBFY() { TranslateMxb Translate = new TranslateMxb(); FrmTranslateMxb frm = new FrmTranslateMxb(); CadBaseSet.RH.MoveBackWindows(frm); frm.Translate = Translate; Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(frm); if (

AutoCAD.Net/C#.Net QQ群:193522571 从已有cuix中导入工作经典空间

[CommandMethod("cloneWS")] public void cloneWorkSpace() { try { string sourceCuiFileName = @"C:\TEST.CUIX"; if (!File.Exists(sourceCuiFileName)) return; string curCuiFileName = Application.GetSystemVariable("MENUNAME").ToStri

AutoCAD.Net/C#.Net QQ群:193522571 从已有A.DWG中复制块BLK到新DWG中的方法

1.新建一个Database,new Database(true, false); 2.以A.DWG为原型新建一个Database,new Database(false,true); 3.将2中的块表记录复制到1的块表中: 4.新建一个块参照,new BlockReference(blockReferencePoint, blocoId); 5.插入到1的Database中,InsertBlockReference(db, blockReference); 对于已有的DWG:new Databa

AutoCAD.Net/C#.Net QQ群:193522571 c#链接到网址

/// <summary> /// 链接到当前地址 /// </summary> /// <param name="URL"></param> public static void LinkTo(this string URL) { ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe"); startInfo.WindowStyle = Pro