找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 2119|回复: 6

[求助]:CAD2002下AcDbSortentsTable的使用,请晓东指教

[复制链接]
发表于 2004-9-15 12:01:04 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我在论坛上搜索了以前的帖子,在文章中心也拜读了你的相关文章,但是还是弄不明白.下面是我的一段代码例子.
void test()
{
        // TODO: Implement the command
        AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
    ASSERT(pDb != NULL);
        Acad::ErrorStatus es;
        AcDbBlockTable* pTable=NULL;
        es=pDb->getBlockTable(pTable,AcDb::kForRead);
        if(es!=Acad::eOk)
        {
                acutPrintf("\n获取块表出错!");
                return;
        }
        AcDbBlockTableRecord* pRec;
        es=pTable->getAt(ACDB_MODEL_SPACE,pRec,AcDb::kForRead);
        pTable->close();
        if(es!=Acad::eOk)
        {
                acutPrintf("\n获取模型空间块记录出错!");
                return;
        }
        AcDbObjectId exDictId=pRec->extensionDictionary();
        pRec->close();
        if(exDictId==AcDbObjectId::kNull)
        {
                acedAlert("第一次使用显示排序,请先使用一次随意draworder命令!");       
                return;
        }
       
        AcDbObjectIdArray objIds;
        ads_name ss;
        int rc = acedSSGet(NULL, NULL, NULL, NULL, ss);
        if(rc != RTNORM)
                return;       
        long length;
        acedSSLength(ss, &length);
        if(length == 0)
        {
                acedSSFree(ss);
                return;
        }
        ads_name entName;
        AcDbObjectId oId;
        for(long i=0; i<length; i++)
        {
                acedSSName(ss, i, entName);
                if(acdbGetObjectId(oId, entName)!=Acad::eOk)
                {
                        acedSSFree(ss);
                        return;
                }
                objIds.append(oId);
        }
        acedSSFree(ss);
        acutPrintf("\n%d",objIds.length());       
       
        AcDbDictionary *pDict;
        es=acdbOpenObject(pDict,exDictId,AcDb::kForWrite);
        AcDbSortentsTable* pSt;
    es=pDict->getAt("ACAD_SORTENTS", (AcDbObject*&)pSt,
        AcDb::kForWrite);         
        es=pSt->moveToTop(objIds);       
        es=pDict->close();
        //pSt如何关闭呀,执行后没有效果
}
我又采用ads的方法读取AcDbSortents的值,代码如下:
        AcDbObjectId stId;
        es=pDict->getAt("ACAD_SORTENTS",stId);
        es=pDict->close();
        ads_name en;
        es=acdbGetAdsName(en,stId);
        resbuf* buf,*eb;
        buf=acdbEntGet(en);
        for (eb = buf; eb != NULL; eb = eb->rbnext)
        printdxf(eb);        
        // Release the acdbEntGet() list.
    acutRelRb(buf);        
不知道可不可以采用acdbEntMod()的方法来进行排序,另外发现CAD的图形句柄是递增的,如果图形的显示顺序是新实体在前,旧实体在后,AcDbSortents中不会包含实体的名称句柄列表。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2004-9-17 22:58:12 | 显示全部楼层
你好,你的问题解决了吗?请教一下AcDbSortentsTable类用那个头文件和库?如果已经解决,请告知解决方法

还有谁用过这个类的?请不吝赐教怎么使用。论坛上现在只能搜索到提问的帖子了:(
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2004-9-20 21:51:39 | 显示全部楼层
没有解决,最近晓东好像没有上来过.
就是网上列的那些类,自己做了个头文件,加入即可,能够编译成功和运行,我试着通过ADS方式能够获取信息.
头文件:
#if !defined(AcDbSortentsTable_H)
#define AcDbSortentsTable_H
class AcDbSortentsTable
{
public:               
        static AcRxClass * AcDbSortentsTable::desc(void);
        virtual AcRxClass * AcDbSortentsTable::isA(void);
        AcDbSortentsTable::AcDbSortentsTable(void);
        virtual AcDbSortentsTable::~AcDbSortentsTable(void);
        int AcDbSortentsTable::sortAs(AcDbObjectId,AcDbHandle &);
        enum Acad::ErrorStatus AcDbSortentsTable::remove( AcDbObjectId);
        enum Acad::ErrorStatus AcDbSortentsTable::moveToBottom(AcDbObjectIdArray &);
        enum Acad::ErrorStatus AcDbSortentsTable::moveToTop(AcDbObjectIdArray &);
        enum Acad::ErrorStatus AcDbSortentsTable::moveBelow(AcDbObjectIdArray &,AcDbObjectId);
        enum Acad::ErrorStatus AcDbSortentsTable::moveAbove(AcDbObjectIdArray &,AcDbObjectId);
        enum Acad::ErrorStatus AcDbSortentsTable::swapOrder(AcDbObjectId,AcDbObjectId);
        enum Acad::ErrorStatus AcDbSortentsTable::setBlockId(AcDbObjectId);
        AcDbObjectId AcDbSortentsTable::blockId(void);
        virtual enum Acad::ErrorStatus AcDbSortentsTable::applyPartialUndo(AcDbDwgFiler *, AcRxClass *);
        virtual enum Acad::ErrorStatus AcDbSortentsTable::dwgInFields(AcDbDwgFiler *);
        virtual enum Acad::ErrorStatus AcDbSortentsTable::dwgOutFields(AcDbDwgFiler *);
        virtual enum Acad::ErrorStatus AcDbSortentsTable::dxfInFields(AcDbDxfFiler *);
        virtual enum Acad::ErrorStatus AcDbSortentsTable::dxfOutFields(AcDbDxfFiler *);
        static void AcDbSortentsTable::rxInit(void);
};
#endif

唉,老大是不是退隐江湖了。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-9-24 11:18:42 | 显示全部楼层
AcDbSortentsTable是做什么用的?我怎么在帮助中找不到相关的说明,楼上的哥们能否解释一下,代码看不太懂。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-10-10 16:01:37 | 显示全部楼层
AcDbSortentsTable is the persistent container for draw order information. It resides in the extension dictionary of an associated AcDbBlockTableRecord under the key ACAD_SORTENTS.

AcDbSortentsTable contains a set of object ID/handle pairs. The object ID is that of the entity to be drawn, and the handle is that of an entity in the block table record (usually but not always different from the associated object ID), which represents the position in the draw order. Entities are appended to a block table record in order of ascending handle value; in other words, the higher the handle value, the later it appears in a block table record. When it's time to draw entities in a block table record, an iterator goes through the block table record in append order. At each entity, the handle value is obtained and used to query into the sortents table. If there is a match, the object ID associated with the handle value in the sortents table is drawn. If there is no match in the sortents table, then the entity at the iterator position is drawn in its "natural" order.

When the draw order of entities is modified, many of the entries in the sortents table may be modified. For example, a block table record has five entities with the following handles (usually represented as strings representing hexadecimal numbers): 4A, 4B, 4C, 4D, 4E. These handles appear in ascending order. When an application iterates over the entities in a block table record in the default direction, the handle value always increases from one entity to the next.

Inherits From
AcRxObject
|--AcGiDrawable
 |--AcDbObject
  |--AcDbSortentsTable

Include File
sorttab.h
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-12-27 10:19:11 | 显示全部楼层
"sorttab.h "哪个版本的开发包里有?
还有,对应的库文件呢?

斑竹,这个类的使用能否给个使用实例,目前论坛上好像没有一个真正的解决方法。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2005-8-26 10:19:35 | 显示全部楼层
楼主的程序下面加入更新的代码就有反应了,另外应该声明class AcDbSortentsTable :  : public AcDbObject,这样就可以直接关闭,要加入的代码如下:

  1.         pSt->close();

  2.         AcDbEntity *pEnt;
  3.         for(i=0; i < length; i++)
  4.         {
  5.                 acedSSName(ss, i, entName);
  6.                 if(acdbGetObjectId(oId, entName)==Acad::eOk)
  7.                 {
  8.                         if(acdbOpenAcDbEntity(pEnt,oId,AcDb::kForWrite)==Acad::eOk)
  9.                         {
  10.                                 pEnt->recordGraphicsModified();
  11.                                 pEnt->downgradeOpen();
  12.                                 pEnt->draw();
  13.                                 pEnt->close();
  14.                         }
  15.                 }
  16.         }
复制代码
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-6-26 21:21 , Processed in 0.271472 second(s), 43 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表