public class DrawOrderTable : Autodesk.AutoCAD.DatabaseServices.DBObject
Member of Autodesk.AutoCAD.DatabaseServices
Summary:
Is the persistent container for draw order information. It resides in the extension dictionary of an associated BlockTableRecord under the key ACAD_SORTENTS.
| Method | Description |
| FirstEntityIsDrawnBeforeSecond | Returns true if first is drawn before second. |
| GetFullDrawOrder | SYstem Returns an collection of the entity object IDs of the block in the order in which they would be... more |
| GetRelativeDrawOrder | Rearranges the object IDs in the input array into their current relative draw order. When one or more bits of... more |
| GetSortHandle | Given an input object ID, this function returns the Handle that indicates the draw order. Entities with lesser handle values... more |
| MoveAbove | Places all the entities specified in the input object ID array above the specified target entity. The entities being moved... more |
| MoveBelow | Places all the entities specified in the input object ID array below the specified target entity. The entities being moved... more |
| MoveToBottom | Places all the entities specified in the input object ID array at the beginning of the draw order. The entities... more |
| MoveToTop | Places all the entities specified in the input object ID array at the ending of the draw order. The entities... more |
| SetRelativeDrawOrder | Takes the object IDs in the input collection and moves them in their current associated draw order slots so that... more |
| SwapOrder | Swaps the draw order positions of the entities. |
Sample Code:

DrawOrder#region DrawOrder
[CommandMethod("DrawOrderTest")]
public void DrawOrderTest()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = Application.DocumentManager.MdiActiveDocument.Database;
Editor ed = doc.Editor;
ObjectId id1 = ObjectId.Null;
ObjectId id2 = ObjectId.Null;
try
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForWrite, false);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);
//Get the DrawOrderTable
DrawOrderTable orderTable = tr.GetObject(btr.DrawOrderTableId, OpenMode.ForWrite) as DrawOrderTable;
PromptEntityOptions entOpt = new PromptEntityOptions("\nSelect first");
PromptEntityResult entRes = ed.GetEntity(entOpt);
if (entRes.Status != PromptStatus.OK) return;
id1 = entRes.ObjectId;
entOpt.Message = "\nSelect second";
do
{
entRes = ed.GetEntity(entOpt);
if (entRes.Status != PromptStatus.OK) return;
id2 = entRes.ObjectId;
entOpt.Message = "\nYou selected one and the same entity, select again";
} while (id2 == id1);
if (id1 != ObjectId.Null && id2 != ObjectId.Null)
{
//if (orderTable.FirstEntityIsDrawnBeforeSecond(id1, id2)) //Why it will be crash?
{
//orderTable.SwapOrder(id1, id2); //Why it didn't execute?
ObjectIdCollection ids = new ObjectIdCollection();
ids.Add(id1);
orderTable.MoveAbove(ids, id2); //It's OK.
//orderTable.MoveBelow(ids, id2); //It's OK.
//orderTable.MoveToBottom(ids); //It's OK.
//orderTable.MoveToTop(ids); //It's OK.
}
}
tr.Commit();
}
}
catch (Autodesk.AutoCAD.Runtime.Exception exc)
{
}
}
#endregion
转载于:https://www.cnblogs.com/wf225/archive/2008/11/14/1333852.html
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删