设为首页收藏本站

中国膜结构网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

膜结构车棚
膜结构车棚膜结构资质国产膜材 膜结构网中国膜结构协会
查看: 247|回复: 5

集合--purge函数

[复制链接]
  • TA的每日心情
    开心
    2021-6-23 14:19
  • 签到天数: 1543 天

    [LV.Master]伴坛终老

    发表于 2021-2-26 08:51 | 显示全部楼层 |阅读模式
    cad.exe已输出了了两个purge函数,只是没在头文件中列出来:
    Acad::ErrorStatus purgeDatabase(AcDbDatabase *pDb);
    Acad::ErrorStatus purgeObjectsFromDatabase(AcDbDatabase *pDb,const AcDbObjectIdArray &Objs);
    用之前声明一下就可以了,它们从acad.lib中输入,几乎所有版本的cad都有。
    1. acdbDatabase::purge()
    2. void PurgeBlock(AcDbDatabase *pDb)
    3. {
    4. AcDbBlockTable *pBlockTable;
    5. pDb->getSymbolTable(pBlockTable, AcDb::kForRead);
    6. AcDbBlockTableRecord *pBlockTableRecord;
    7. pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,
    8. AcDb::kForWrite);
    9. pBlockTable->close();
    10. AcDbBlockTableRecordIterator *pBlkRcdItr; //块表记录浏览器
    11. pBlockTableRecord->newIterator(pBlkRcdItr);
    12. AcDbObjectId id;
    13. AcDbObjectIdArray idArr;
    14. for(pBlkRcdItr->start();!pBlkRcdItr->done();pBlkRcdItr->step())
    15. {
    16. pBlkRcdItr->getEntityId(id);
    17. idArr.append(id); //向数组添加实体
    18. }
    19. pDb->purge(idArr); //清理垃圾
    20. pBlockTableRecord->close();
    21. delete pBlkRcdItr;
    22. }
    复制代码
    回复


    http://www.mjgw.org/ 专业从事膜结构设计、制作加工、施工安装的膜结构工程服务,能够为客户提供专业的膜结构整体解决方案。做中国最好的膜结构综合服务平台。欢迎大家联系电话:198-7840-1958,QQ:463017170.
    相关关键词:膜结构车棚,膜结构车棚覆盖,膜结构车棚公司,膜结构车棚多少钱,膜结构车棚厂家,膜结构车棚价格,社区膜结构车棚,膜结构车棚膜布厂家 ,膜结构车棚哪家好,膜结构车棚多少钱一米,膜结构车棚报价,膜结构车棚哪里有,膜结构车棚定制,膜结构车棚安装,膜结构车棚设计,膜结构车棚电话,膜结构车棚加工,膜结构车棚膜布价格,膜结构车棚批发,膜结构车棚制造商,膜结构车棚生产厂家,膜结构车棚设计,膜结构车棚施工,膜结构车棚多少钱一平米,膜结构车棚订制,张拉膜车棚,张拉膜车棚覆盖,张拉膜车棚公司,张拉膜车棚多少钱,张拉膜车棚厂家,张拉膜车棚价格,社区张拉膜车棚,张拉膜车棚膜布厂家 ,张拉膜车棚哪家好,张拉膜车棚多少钱一米,张拉膜车棚报价,张拉膜车棚哪里有,张拉膜车棚定制,张拉膜车棚安装,张拉膜车棚设计,张拉膜车棚电话,张拉膜车棚加工,张拉膜车棚膜布价格,张拉膜车棚批发,张拉膜车棚制造商,张拉膜车棚生产厂家,张拉膜车棚设计,张拉膜车棚施工,张拉膜车棚多少钱一平米,张拉膜车棚订制,常用膜材品牌:德国杜肯、法国法拉利、德国海德斯、德国米乐、日本平岗、韩国秀博、比利时希运、美国赫虏伯、中国科宝、上海慧遥。

    使用道具 举报

  • TA的每日心情
    开心
    2021-6-23 14:19
  • 签到天数: 1543 天

    [LV.Master]伴坛终老

     楼主| 发表于 2021-2-26 08:54 | 显示全部楼层
    阻止块被PURGE
    Preventing a block from being purged
    By Balaji Ramamoorthy

    We will look at two approaches to prevent a block from getting purged.

    1) Create a block reference out of the block and assign it to a hidden layer

    2) Create a custom object that stores a hard pointer to the block. An instance of the custom object can be stored within your dictionary stored under the named object dictionary.

    Here is the code snippet for the first method :
    1. static Acad::ErrorStatus CreateBlock_Method1()
    2. {
    3.     Acad::ErrorStatus es;
    4.     AcDbBlockTable *pBlockTable = NULL;

    5.     AcDbDatabase *pDb
    6.             = acdbHostApplicationServices()->workingDatabase();

    7.     pDb->getBlockTable(pBlockTable, AcDb::kForWrite);
    8.     AcDbBlockTableRecord* pAnonBlock = new AcDbBlockTableRecord();
    9.     pAnonBlock->setName(_T("*U"));

    10.     AcDbObjectId idAnonBlock = AcDbObjectId::kNull;
    11.     pBlockTable->add(idAnonBlock, pAnonBlock);

    12.     AcDbCircle *pCircle = new AcDbCircle(
    13.                                             AcGePoint3d::kOrigin,
    14.                                             AcGeVector3d::kZAxis,
    15.                                             5.0
    16.                                         );

    17.     pAnonBlock->appendAcDbEntity(pCircle);

    18.     pCircle->close();

    19.     pAnonBlock->close();

    20.     // Method : 1
    21.     // Create an anonymous layer and use it for the
    22.     // newly created block reference.
    23.     AcDbObjectId layerId = AcDbObjectId::kNull;
    24.     AcDbLayerTable* lTable;
    25.     es = pDb->getSymbolTable(lTable, AcDb::kForWrite);

    26.     if(Acad::eOk == es && lTable)
    27.     {
    28.         AcDbLayerTableRecord* lTblRec = new AcDbLayerTableRecord;
    29.         lTblRec->setName(ACRX_T("TEST"));
    30.         lTblRec->setIsHidden(true);
    31.         AcCmColor layerColor;
    32.         layerColor.setColorIndex(2);
    33.         lTblRec->setColor(layerColor);

    34.         if (lTable->add(layerId, lTblRec) != Acad::eOk)
    35.             AfxMessageBox(_T("ERROR Creating Layer"));
    36.         else
    37.             lTblRec->close();

    38.         lTable->close();
    39.     }

    40.     // Create a block reference and set to the hidden layer
    41.     AcDbBlockReference *pBlkRef
    42.             = new AcDbBlockReference(
    43.                                         AcGePoint3d::kOrigin,
    44.                                         idAnonBlock
    45.                                     );
    46.     pBlkRef->setLayer(layerId, true, true);

    47.     AcDbBlockTableRecord *pModelSpace;
    48.     pBlockTable->getAt(
    49.                         ACDB_MODEL_SPACE,
    50.                         pModelSpace,
    51.                         AcDb::kForWrite
    52.                       );

    53.     pModelSpace->appendAcDbEntity(pBlkRef);

    54.     pBlkRef->close();
    55.     pModelSpace->close();
    56.     pBlockTable->close();

    57.     return Acad::eOk;
    58. }
    59. Here is the code snippet for the second method :

    60. // Step : 1
    61. // Create a basic custom object using the ARX wizard


    62. // Step : 2
    63. // In your custom object header file, add an id that will
    64. // hold the ObjectId of the block that we are trying to
    65. // prevent getting purged.
    66. public:
    67.     // Id of the object to prevent purge
    68.     AcDbObjectId _Id;


    69. // Step : 3
    70. // Ensure that the objectId of the block is filed.
    71. // For this make the following changes to the
    72. // dwgInFields and dwgOutFields methods.
    73. Acad::ErrorStatus AdsMyCustomObj::dwgOutFields
    74.                                     (AcDbDwgFiler *pFiler) const
    75. {
    76.     // ...
    77.     //----- Output params
    78.     pFiler->writeHardPointerId(_Id);

    79.     return (pFiler->filerStatus ()) ;
    80. }

    81. Acad::ErrorStatus AdsMyCustomObj::dwgInFields
    82.                                         (AcDbDwgFiler *pFiler)
    83. {
    84.     // ...
    85.     //----- Read params
    86.     AcDbHardPointerId hardPointerId;
    87.     pFiler->readHardPointerId(&hardPointerId);
    88.     _Id = hardPointerId;

    89.     return (pFiler->filerStatus ()) ;
    90. }


    91. // Step : 4
    92. // Here is the method that creates a block table record
    93. // and stores its id in the custom object instance.
    94. // The custom object instance is stored in a custom dictionary
    95. // under the named object dictionary.
    96. static Acad::ErrorStatus CreateBlock_Method2( )
    97. {
    98.     Acad::ErrorStatus es;
    99.     AcDbBlockTable *pBlockTable = NULL;

    100.     AcDbDatabase *pDb
    101.             = acdbHostApplicationServices()->workingDatabase();

    102.     pDb->getBlockTable(pBlockTable, AcDb::kForWrite);
    103.     AcDbBlockTableRecord* pAnonBlock = new AcDbBlockTableRecord();
    104.     pAnonBlock->setName(_T("*U"));

    105.     AcDbObjectId idAnonBlock = AcDbObjectId::kNull;
    106.     pBlockTable->add(idAnonBlock, pAnonBlock);

    107.     AcDbCircle *pCircle = new AcDbCircle(
    108.                                             AcGePoint3d::kOrigin,
    109.                                             AcGeVector3d::kZAxis,
    110.                                             5.0
    111.                                         );

    112.     pAnonBlock->appendAcDbEntity(pCircle);
    113.     pCircle->close();
    114.     pAnonBlock->close();

    115.     // Method : 2
    116.     // Custom object in the NOD to store the hard pointer
    117.     // to the block
    118.     AcDbObjectPointer<AcDbDictionary> pNOD(
    119.                                             pDb->namedObjectsDictionaryId(),
    120.                                             AcDb::kForWrite
    121.                                           );
    122.     AcDbDictionary *pMyDict = NULL;

    123.     AcDbObject *pMyDictObject = NULL;
    124.     if(pNOD->getAt(
    125.                     ACRX_T("MYOBJDICT"),
    126.                     pMyDictObject,
    127.                     AcDb::kForWrite
    128.                   ) == Acad::eOk)
    129.     {
    130.         pMyDict = AcDbDictionary::cast(pMyDictObject);
    131.     }
    132.     else
    133.     {
    134.         pMyDict = new AcDbDictionary();
    135.         AcDbObjectId DictObjectId = AcDbObjectId::kNull;
    136.         pNOD->setAt(ACRX_T("MYOBJDICT"), pMyDict, DictObjectId);
    137.     }

    138.     AcDbObjectId customObjectId;
    139.     AdsMyCustomObj *pCustObj = new AdsMyCustomObj();
    140.     pCustObj->_Id = idAnonBlock;
    141.     pMyDict->setAt (_T("DETAILS"), pCustObj, customObjectId);
    142.     pCustObj->close ();

    143.     pMyDict->close();
    144.     pNOD->close();

    145.     pBlockTable->close();
    146.     return Acad::eOk;
    147. }
    复制代码
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2021-6-23 14:19
  • 签到天数: 1543 天

    [LV.Master]伴坛终老

     楼主| 发表于 2021-2-26 08:59 | 显示全部楼层
    通常CAD图形中的图块,如果未被引用,可以被purge清理掉,以节省磁盘空间,但有某些块虽未被引用,我仍然需要保留在图形,不让其被清理,可何做到!
    1. 你可以使用反应器:
    2. 普通浏览复制代码

    3. AcEditorReactor::commandWillStart Function virtual void

    4. commandWillStart(

    5. const char* cmdStr);

    6. cmdStr Passed in string of the command being executed

    7. This callback function indicates that the command cmdStr is about to

    8. begin execution.

    9. cmdStr may be up to 257 characters (including the string terminator).
    复制代码
    来判断是否执行了purge 命令,然后你保存你需要的“未被引用”的BLOCK,等AcEditorReactor::commandEnded  时候,你再恢复那些BLOCK到数据库。

    具体可以看联机帮助和ARX目录下面的SAMPLE目录下的例子。

    下面摘自联机帮助,介绍AcEditorReactor::commandEnded
    1. AcEditorReactor::commandEnded Function virtual void

    2. commandEnded(

    3. const char* cmdStr);

    4. cmdStr Passed in string of the command being executed

    5. This callback function indicates that the command cmdStr has completed.


    6. cmdStr may be up to 257 characters (including the string terminator).


    7. With commands involving sets of entities, and when
    8. AcEditorReactor::comandEnded() notification is sent, the last entity

    9. operated upon is still open for read even though AutoCAD is no longer
    10. looking at it. This prevents that entity from being opened for write via
    11. acdbOpenObject() within the notification callback.

    12. There are two ways to get around this limitation:

    13. 1  The preferred method is to use a transaction to manipulate the entities
    14. within your implementation of the commandEnded(). This bypasses any
    15. problems opening objects that are still open.

    16. Warning When using this method, you must be sure to end or terminate

    17. the transaction before you return from the commandEnded() function.

    18. Following is a simple example of this method:

    19. void
    20. AsdkEdReactor::commandEnded(const char *pCommand)
    21. {
    22.     // If AutoCAD is shutting down, then do nothing.
    23.     //
    24.     if (!acdbHostApplicationServices()->working Database())
    25.         return;

    26.     // get entities just operated on
    27.     //
    28.     ads_name sset;
    29.     int err = acedSSGet("p", NULL, NULL, NULL, sset);
    30.     if (err != RTNORM) {
    31.         acutPrintf("\nError acquiring previous selection set");
    32.         return;
    33.     }
    34.     actrTransactionManager->startTransaction();

    35.     long length;
    36.     acedSSLength(sset, &length);

    37.     ads_name en;
    38.     AcDbObjectId eId;
    39.     AcDbEntity *pEnt;
    40.     for (long i=0; i <  length; i++) {
    41.         acedSSName(sset, i, en);

    42.         Acad::ErrorStatus es = acdbGetObjectId(eId, en);
    43.         if (es != Acad::eOk) {
    44.             acutPrintf("\nacdbGetObjectId failed: "
    45.                 "Entity name < %lx,%lx >, error %s.", en[0], en[1],
    46.                 acadErrorStatusText(es));
    47.             acedSSFree(sset);
    48.             return;
    49.         }
    50.         es = actrTransactionManager->getObject((AcDbObject*&)pEnt,
    51.             eId, AcDb::kForWrite);
    52.         if (es == Acad::eOk) {
    53.             pEnt->setColorIndex(1);
    54.             pEnt->close();
    55.         } else {
    56.             acutPrintf("\ngetObject failed with error %s.",
    57.                 acadErrorStatusText(es));
    58.             actrTransactionManager->abortTransaction();
    59.             acedSSFree(sset);
    60.             return;
    61.         }
    62.     }
    63.     actrTransactionManager->endTransaction();
    64.     acedSSFree(sset);
    65. }
    66. 2  Within the commandEnded() implementation, you can open the entity
    67. for read and then repeatedly call its close() method until its isReallyClosing
    68. () method returns Acad::kTrue, indicating that there is now only one
    69. reader, and then use the entity's upgradeOpen() method to upgrade the
    70. open to AcDb::kForWrite.

    71. Now the entity is in a normal open AcDb::kForWrite state, so do whatever
    72. operations you want, followed by a call to the entity's close() or cancel()

    73. .
    74. Following is a simple example of this method:

    75. void
    76. AsdkEdReactor::commandEnded(const char *pCommand)
    77. {
    78.     // If AutoCAD is shutting down, then do nothing.
    79.     //
    80.     if (!acdbHostApplicationServices()->working Database())
    81.         return;
    82.    
    83.     // get entities just operated on
    84.     //
    85.     ads_name sset;
    86.     int err = acedSSGet("p", NULL, NULL, NULL, sset);
    87.     if (err != RTNORM) {
    88.         acutPrintf("\nError acquiring previous selection set");
    89.         return;
    90.     }

    91.     long length;
    92.     acedSSLength(sset, &length);

    93.     ads_name en;
    94.     AcDbObjectId eId;
    95.     AcDbEntity *pEnt;
    96.     for (long i=0; i < length; i++) {
    97.         acedSSName(sset, i, en);

    98.         Acad::ErrorStatus es = acdbGetObjectId(eId, en);
    99.         if (es != Acad::eOk) {
    100.             acutPrintf("\nacdbGetObjectId failed: "
    101.                 "Entity name < %lx,%lx >, error %s.", en[0], en[1],
    102.                 acadErrorStatusText(es));
    103.             acedSSFree(sset);
    104.             return;
    105.         }
    106.         es = acdbOpenObject(pEnt, eId, AcDb::kForWrite);
    107.         if (es == Acad::eOk) {
    108.             pEnt->setColorIndex(cindex);
    109.             pEnt->close();
    110.         } else if (es == Acad::eWasOpenForRead) {
    111.             // open it for read again to get a pointer to the
    112.             // entity and then close it repeatedly until it's
    113.             // down to one open for read.
    114.             //
    115.             acdbOpenObject(pEnt, eId, AcDb::kForRead);
    116.             do
    117.                 pEnt->close();
    118.             while (!pEnt->isReallyClosing());

    119.             // Now that we're down to one open for read, upgrade
    120.             // the open to kForWrite.
    121.             //
    122.             pEnt->upgradeOpen();

    123.             // do what we want and then close
    124.             //
    125.             pEnt->setColorIndex(1);
    126.             pEnt->close();
    127.         } else {
    128.             acutPrintf("\nacdbOpenObject failed with error %s.",
    129.                 acadErrorStatusText(es));
    130.             acedSSFree(sset);
    131.             return;
    132.         }
    133.     }
    134.     acedSSFree(sset);
    135. }
    复制代码
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2021-6-23 14:19
  • 签到天数: 1543 天

    [LV.Master]伴坛终老

     楼主| 发表于 2021-2-26 09:02 | 显示全部楼层
    清除嵌套匿名块
    1. Acad::ErrorStatus Grazie::purge()
    2. {
    3.     Acad::ErrorStatus es;
    4.     AcDbObjectIdArray ids;
    5.     AcDbObjectId id;

    6.     CString nome=L"";
    7.     AcDbObjectId tblRecId;

    8.     AcDbDatabase *pDbUse=acdbHostApplicationServices()->workingDatabase();
    9.     ids.setLogicalLength(0).setPhysicalLength(0);

    10.     AcDbBlockTable *pBlockTable;
    11.     es=acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForWrite);

    12.     AcDbBlockTableIterator* tblIter;
    13.     es = pBlockTable->newIterator(tblIter);
    14.     if (es == Acad::eOk)
    15.     {
    16.       // walk table and just collect all the objIds
    17.       // of the entries
    18.         for (; !tblIter->done(); tblIter->step())
    19.         {
    20.             AcDbBlockTableRecord* blkRec;
    21.             es = tblIter->getRecord(blkRec, AcDb::kForWrite);
    22.             if (es == Acad::eOk)
    23.             {
    24.                 //if(blkRec->isKindOf(AcDbBlockReference::desc()))
    25.                 {
    26.                     if (blkRec->isAnonymous())
    27.                     {
    28.                         ACHAR* locName;
    29.                         blkRec->getName(locName);
    30.                         id=blkRec->id();
    31.                         ids.append(id);
    32.   
    33.                     }
    34.                 }
    35.                 blkRec->close();
    36.             }
    37.         }
    38.         delete tblIter;
    39.     }
    40.     pBlockTable->close();

    41.     es=pDbUse->purge(ids);

    42.     es = pBlockTable->newIterator(tblIter);
    43.     if (es == Acad::eOk)
    44.     {
    45.       // walk table and just collect all the objIds
    46.       // of the entries
    47.         for (; !tblIter->done(); tblIter->step())
    48.         {
    49.             AcDbBlockTableRecord* blkRec;
    50.             es = tblIter->getRecord(blkRec, AcDb::kForWrite);
    51.             if (es == Acad::eOk)
    52.             {
    53.                 //if(blkRec->isKindOf(AcDbBlockReference::desc()))
    54.                 {
    55.                     if (blkRec->isAnonymous())
    56.                     {
    57.                         ACHAR* locName;
    58.                         blkRec->getName(locName);
    59.                         id=blkRec->id();
    60.                         if(ids.find(id)>=0)
    61.                         {
    62.                             nome=L"";
    63.                             nome=locName;
    64. //                            if(nome.Find(L"*D")==0 || nome.Find(L"*U")==0)
    65.                                 es=blkRec->erase();
    66.                         }
    67.                     }
    68.                 }
    69.                 blkRec->close();
    70.             }
    71.         }
    72.         delete tblIter;
    73.     }
    74.     pBlockTable->close();
    75.     ids.setLogicalLength(0).setPhysicalLength(0);

    76.     return es;

    77. }
    复制代码
    Besides that the second call of   es = pBlockTable->newIterator(tblIter);   is carried out after pBlockTable was closed!



    By the way: If you use a non-const ACHAR* for

                ACHAR* locName;
                blkRec->getName(locName);

    You have to release the memory for it with acutDelString(locName)! I recomment using   const ACHAR *locName=NULL;  instead. You don't have to release the memory than.
    1. int i, nCount = ids.length();
    2.         for (i = 0; i < nCount; ++i)
    3.         {
    4.                 AcDbBlockTableRecord* blkRec=NULL;
    5.                 if ( (es=acdbOpenObject(blkRec, ids[i], AcDb::kForWrite)) == Acad::eOk )
    6.                 {
    7.                         es = blkRec->erase();
    8.                         blkRec->close();               
    9.                 }
    10.         }
    复制代码
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2021-6-23 14:19
  • 签到天数: 1543 天

    [LV.Master]伴坛终老

     楼主| 发表于 2021-2-26 09:08 | 显示全部楼层
    使用硬指针防止清除文本样式
    1. bool setXdata()
    2. {
    3. AcDbDictionary *pNamedobj;
    4. AcDbDictionary *pDict;
    5. AcDbXrecord *pXrec;
    6. AcDbObjectId dictObjId, xrecObjId;
    7. struct resbuf *prbXtn;


    8. acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary(
    9. pNamedobj, AcDb::kForWrite);

    10. // if not exist make new

    11. if (pNamedobj->getAt("CCNC_Brandschutz", (AcDbObject*&) pDict,
    12. AcDb::kForWrite) == Acad::eKeyNotFound)
    13. {
    14. pDict = new AcDbDictionary;
    15. pNamedobj->setAt("CCNC_Brandschutz", pDict, dictObjId);
    16. }

    17. // if no xrecord make new

    18. pNamedobj->close();

    19. if (pDict->getAt("CCNC_Fluchtweg", (AcDbObject*&)pXrec, AcDb::kForWrite) ==
    20. Acad::eKeyNotFound)
    21. {
    22. pXrec = new AcDbXrecord;
    23. pDict->setAt("CCNC_Fluchtweg", pXrec, xrecObjId);
    24. }

    25. pDict->close();

    26. char version[12] = "Version_1.0";

    27. AcDbDatabase *pCurDb = NULL;
    28. AcDbLayerTable *pLayerTable;
    29. AcDbObjectId layId;

    30. pCurDb = acdbHostApplicationServices()->workingDatabase();
    31. pCurDb->getLayerTable(pLayerTable, AcDb::kForRead);
    32. pLayerTable->getAt(dlgFlucht.chrLayer, dlgFlucht.idLayer, false);
    33. pLayerTable->close();

    34. ads_name ename;

    35. acdbGetAdsName(ename, dlgFlucht.idLayer);


    36. prbXtn = acutBuildList( AcDb::kDxfText, version,
    37. AcDb::kDxfInt32, dlgFlucht.fl_color,
    38. AcDb::kDxfHardPointerId, ename,
    39. RTNONE);

    40. if(pXrec->setFromRbChain(*prbXtn) != Acad::eOk)
    41. {
    42. acutPrintf("\nFailed");
    43. }

    44. pXrec->close();

    45. acutRelRb(prbXtn);

    46. return true;
    47. }

    48. here is the read out:

    49. bool getXdata()
    50. {
    51. AcDbDictionary *pNamedDict;
    52. AcDbDictionary *pDict;
    53. AcDbXrecord *pXrec;
    54. AcDbObjectId idLayer;
    55. struct resbuf *prbXtn, *pTemp;


    56. acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary(
    57. pNamedDict, AcDb::kForRead);

    58. if (pNamedDict->getAt("CCNC_Brandschutz", (AcDbObject*&) pDict,
    59. AcDb::kForWrite) == Acad::eKeyNotFound)
    60. {
    61. pNamedDict->close();
    62. return false;
    63. }

    64. pNamedDict->close();

    65. if (pDict->getAt("CCNC_Fluchtweg", (AcDbObject*&)pXrec, AcDb::kForRead) ==
    66. Acad::eKeyNotFound)
    67. {
    68. pDict->close();
    69. return false;
    70. }

    71. pDict->close();
    72. pXrec->rbChain(&prbXtn);
    73. pXrec->close();
    74. pTemp = prbXtn;

    75. pTemp = pTemp->rbnext;
    76. if(pTemp->restype == AcDb::kDxfInt32)
    77. dlgFlucht.fl_color = pTemp->resval.rint;
    78. else
    79. return false;

    80. pTemp = pTemp->rbnext;

    81. ads_name ename;

    82. if(pTemp->restype == AcDb::kDxfHardPointerId)
    83. memcpy(ename, pTemp->resval.rlname, sizeof(ads_name));
    84. else
    85. return false;

    86. AcDbObjectId layId;

    87. acdbGetObjectId(layId, ename);
    88. dlgFlucht.idLayer = layId;

    89. ads_relrb(prbXtn);

    90. return true;
    91. }
    复制代码
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2021-6-23 14:19
  • 签到天数: 1543 天

    [LV.Master]伴坛终老

     楼主| 发表于 2021-2-26 09:30 | 显示全部楼层
    以编程方式删除表块记录
    1. OdDbDatabase *pDb = odapDocManager()->curDocument()->database();
    2. pDb->disableUndoRecording(false);
    3. pDb->startUndoRecord();

    4. OdDbBlockReferencePtr pMyBlockRef=m_MyObjectID.safeOpenObject(OdDb::kForWrite);
    5. pMyBlockRef->erase(); // first erase the selected reference

    6. after this in erase reactor function:

    7. void DbReactor::objectErased(const OdDbDatabase* pDb,const OdDbObject* pObject,bool erased)
    8. {
    9.    if ( !processUndo(pObject) )
    10.    {
    11.       callCallback(SDS_CBENTDEL,pObject);

    12.                //......additional code to test if the block reference is the one I try to erase
    13.                // if(yes) do...{ code below }

    14.       OdDbObjectIdArray aObjIds;
    15.       aObjIds.push_back(pObject->objectId());

    16.       pDb->purge(aObjIds); //purge all references
    17.       OdDbBlockTableRecordPtr pBlockTable = OdDbBlockReferencePtr(pObject)->blockTableRecord().safeOpenObject(OdDb::kForWrite);
    18.                 pBlockTable ->erase(); // erase block table container
    19.    
    20.    }
    21. }
    复制代码
    回复 支持 反对

    使用道具 举报

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

    本版积分规则

    关闭

    推荐膜材品牌上一条 /6 下一条

    进口膜材 国产膜材 pvdf膜材ptfe膜材ETFE膜材
    最好的膜结构公司 一级膜结构资质 膜结构一级资质
    膜结构设计-膜结构十大品牌-etfe设计-充气膜结构
    诺科膜结构
    遨都膜结构设计
    中国膜结构网
    中国空间膜结构

    QQ|申请友链|手机版|中国膜结构论坛