不用遍历得到btr中同一类型的实体 CAD2009 vs2008及以上

              var dict =
                    from ObjectId id in btr
                    group id by id.ObjectClass.DxfName;

                foreach (var ids in dict)
                {

                    switch (ids.Key)
                    {
                        case "LINE":
                            foreach (var id in ids)
                            {
                                Entity ent = id.GetObject(OpenMode.ForWrite) as Entity;
                                ent.ColorIndex = 1;
                            }
                            break;
                        case "CIRCLE":
                            foreach (var id in ids)
                            {
                                Entity ent = id.GetObject(OpenMode.ForWrite) as Entity;
                                ent.ColorIndex = 3;
                            }
                            break;
                    }
                }

                tr.Commit

posted @ 2010-01-14 14:12  houlinbo  阅读(334)  评论(0编辑  收藏  举报