许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  AutoCAD.NET开发教程:DrawOrder修改图形中实体显示顺序

AutoCAD.NET开发教程:DrawOrder修改图形中实体显示顺序

阅读数 1
点赞 0
article_banner

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.

Methods


MethodDescription
FirstEntityIsDrawnBeforeSecondReturns true if first is drawn before second.
GetFullDrawOrderSYstem Returns an collection of the entity object IDs of the block in the order in which they would be... more
GetRelativeDrawOrderRearranges the object IDs in the input array into their current relative draw order. When one or more bits of... more
GetSortHandleGiven an input object ID, this function returns the Handle that indicates the draw order. Entities with lesser handle values... more
MoveAbovePlaces all the entities specified in the input object ID array above the specified target entity. The entities being moved... more
MoveBelowPlaces all the entities specified in the input object ID array below the specified target entity. The entities being moved... more
MoveToBottomPlaces all the entities specified in the input object ID array at the beginning of the draw order. The entities... more
MoveToTopPlaces all the entities specified in the input object ID array at the ending of the draw order. The entities... more
SetRelativeDrawOrderTakes the object IDs in the input collection and moves them in their current associated draw order slots so that... more
SwapOrderSwaps the draw order positions of the entities.

Sample Code:

ContractedBlock.gifExpandedBlockStart.gif        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


免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删


相关文章
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空