Example #1
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);
            }
Example #2
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());
            }