Public classDrawordertable:
Autodesk. AutoCAD. databaseservices. dbobject
Member
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.
Methods
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 wocould be...More |
Getrelativedraworder |
Rearranges the object IDs in the input array into their current relative draw order. When one or more bits...More |
Getsorthandle |
Given an input Object ID, this function returnsHandleThat indicates the draw order. Entities with lesser handle values...More |
Moveabve |
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. moveabve (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