private static ObjectIdCollection MoveWipeoutsToBottom(Transaction tr, ObjectIdCollection ids)
{
ObjectIdCollection brIds = new ObjectIdCollection();
RXClass wc = RXObject.GetClass(typeof(Wipeout));
// Take a copy of the IDs passed in, as we'll modify the
// original list for the caller to use
ObjectId[] btrIds = new ObjectId[ids.Count];
ids.CopyTo(btrIds, 0);
// Loop through the blocks passed in, opening each one
foreach (ObjectId btrId in btrIds)
{
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForWrite);
// Collect the wipeouts in the block
ObjectIdCollection wipeouts = new ObjectIdCollection();
foreach (ObjectId id in btr)
{
Entity ent = (Entity)tr.GetObject(id, OpenMode.ForRead);
if (ent.GetRXClass().IsDerivedFrom(wc))
{
wipeouts.Add(id);
}
}
// Move the collected wipeouts to the bottom
if (wipeouts.Count > 0)
{
// Modify the draw order table, if we have wipepouts
DrawOrderTable dot = (DrawOrderTable)tr.GetObject(btr.DrawOrderTableId, OpenMode.ForWrite);
dot.MoveToBottom(wipeouts);
// Collect the block references to this block, to pass
// back to the calling function for updating
ObjectIdCollection btrBrIds = btr.GetBlockReferenceIds(false, false);
foreach (ObjectId btrBrId in btrBrIds)
{
brIds.Add(btrBrId);
}
}
else
{
ids.Remove(btrId);
}
}
return brIds;
}