Autocad.net: draworder-change display order of the entities in the drawing

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.