Ejemplo n.º 1
0
            public static ObjectId FindParcelOfHole(Transaction tr, Entity hole)
            {
                var      entityIds = GroupUtils.GetGroupedObjects(tr, hole);
                ObjectId entityId  = ObjectId.Null;

                foreach (var objectId in entityIds)
                {
                    if (objectId == hole.Id)
                    {
                        continue;
                    }

                    using (var ent = tr.GetObject(objectId, OpenMode.ForRead))
                    {
                        if (ent is Polyline2d || ent is Polyline)
                        {
                            string cassFlag = CadUtils.GetCassFlag(ent);
                            if (CassFlagName.ToLower() == cassFlag.ToLower())
                            {
                                entityId = objectId;
                                break;
                            }
                        }
                    }
                }
                return(entityId);
            }
Ejemplo n.º 2
0
            static bool IsPolygonHasHole(Transaction tr, Entity entity)
            {
                ObjectId[] entityIds = GroupUtils.GetGroupedObjects(tr, entity);
                foreach (ObjectId entityId in entityIds)
                {
                    // 如果是本地块,直接skip
                    if (entity.ObjectId == entityId)
                    {
                        continue;
                    }

                    using (var ent = tr.GetObject(entityId, OpenMode.ForRead))
                    {
                        if (ent is Polyline2d || ent is Polyline)
                        {
                            string cassFlag = CadUtils.GetCassFlag(ent);
                            if (CassFlagIsland.ToLower() == cassFlag.ToLower())
                            {
                                return(true);
                            }
                        }
                    }
                }

                return(false);
            }
Ejemplo n.º 3
0
            public static void CleanupSelfRefHoles(ObjectId[] holeIds)
            {
                var database = holeIds[0].Database;

                using (var tr = database.TransactionManager.StartTransaction())
                {
                    foreach (var holeId in holeIds)
                    {
                        var hole = database.TransactionManager.GetObject(holeId, OpenMode.ForRead) as Entity;
                        var col  = hole.GetPersistentReactorIds();
                        if (col != null)
                        {
                            foreach (ObjectId id in col)
                            {
                                using (DBObject obj = tr.GetObject(id, OpenMode.ForRead))
                                {
                                    if (obj is Group)
                                    {
                                        var group = obj as Group;
                                        group.UpgradeOpen();
                                        var objectIds = GroupUtils.GetGroupedObjects(tr, hole);
                                        // 如果组里面只有一个,直接删除组
                                        if (objectIds.Count() == 1)
                                        {
                                            group.Erase();
                                        }
                                        // 如果组里面有两个,并且两个编码一样
                                        if (objectIds.Count() == 2 && objectIds[0] == objectIds[1])
                                        {
                                            group.Erase();
                                        }
                                    }
                                }
                            }
                        }
                    }

                    tr.Commit();
                }
            }
Ejemplo n.º 4
0
            public static ObjectId[] FindHolesInEntity(Transaction tr, Entity entity)
            {
                ObjectId[] entityIds = GroupUtils.GetGroupedObjects(tr, entity);

                var holeIds = new List <ObjectId>();

                foreach (ObjectId entityId in entityIds)
                {
                    using (var ent = tr.GetObject(entityId, OpenMode.ForRead))
                    {
                        if (ent is Polyline2d || ent is Polyline)
                        {
                            string cassFlag = CadUtils.GetCassFlag(ent);
                            if (CassFlagIsland.ToLower() == cassFlag.ToLower())
                            {
                                holeIds.Add(entityId);
                            }
                        }
                    }
                }

                return(holeIds.ToArray());
            }