Theclass 提供了四个通知函数,这些函数在深层克隆操作中的某些点将控制权返回给应用程序。在所有深度克隆和 wblock 克隆操作期间调用以下函数:AcEditorReactor
该函数在创建实例之后和克隆任何对象之前调用。ID 映射将为空,但此时可以查询。beginDeepClone()AcDbIdMappingdestDb()deepCloneContext() 在克隆主选择集中的所有对象之后和转换引用之前调用该函数。这是第一次可以看到ID映射中克隆的整个集合。这也是克隆任何其他对象并将它们添加到 ID 映射的时候。请记住,此时克隆的任何对象的对象 ID 都在不断变化。beginDeepCloneXlation() 该函数在两者之间的任何时间被调用。abortDeepClone()beginDeepClone()endDeepClone() 该函数在克隆和翻译过程结束时调用。对象 ID 不再变化。但是,此调用并不意味着实体对于正在执行的任何命令都处于最终状态。通常会在克隆过程之后转换克隆的实体或执行其他操作。还有其他回调函数可用于稍后访问实体,包括。endDeepClone()commandEnded() 除了前面的四个功能外,wblock 克隆操作中还提供了以下通知功能:
这些调用与深度克隆函数一起按以下顺序出现:
beginWblockObjects()仅在调用函数并正在执行时发送。在克隆每个源数据库的第一个对象之前,将为每个源数据库发送一次该对象。对于,通知序列为:AcDbDatabase::wblockCloneObjects()wblockCloneObjects()
有三种类型。此处列出了它们及其相应的功能:AcEditorReactor::beginWblock()AcDbDatabase 布洛克* virtual void AcEditorReactor::beginWblock( AcDbDatabase* pTo, AcDbDatabase* pFrom) Acad::ErrorStatus AcDbDatabase::wblock( AcDbDatabase*& pOutputDatabase) 用户定义块的 WBLOCK virtual void AcEditorReactor::beginWblock( AcDbDatabase* pTo, AcDbDatabase* pFrom, AcDbObjectId blockId) Acad::ErrorStatus AcDbDatabase::wblock( AcDbDatabase*& pOutputDatabase, AcDbObjectId nObjId) 选择集的 WBLOCK virtual void AcEditorReactor::beginWblock( AcDbDatabase* pTo, AcDbDatabase* pFrom, const AcGePoint3d& insertionPoint) Acad::ErrorStatus AcDbDatabase::wblock( AcDbDatabase*& pOutputDatabase, const AcDbObjectIdArray& pIdSet, const AcGePoint3d& pPoint3d) All three versions clone both the model space and paper space before calling . However, for the entities within these block table records, the order of notification will appear to come differently in the first type and last two types. In version one, entities in model space that are being cloned will receive the call for before the . In versions two and three, entities in the or the selection set will get their call after the notification call. AcDbBlockTableRecordbeginWblock()wblockClone()AcEditorReactor::beginWblock()AcDbBlockTableRecordwblockClone()AcEditorReactor::beginWblock() Objects that have been cloned during a partial XBIND are automatically redirected just after notification. This means that their in the externally referenced database are forwarded to the of the clone objects in the host drawing, and the objects in the externally referenced database are deleted. Objects that reference the forwarded end up referencing the clones in the host drawing. If you need to disable this automatic redirection for your objects, then remove the from the , for your cloned objects, during notification. endDeepClone()AcDbObjectIdsAcDbObjectIdsAcDbObjectIdsidPair()idMapendDeepClone() The following function calls occur during an INSERT or INSERT* command:
These calls come in the following order with the deep clone functions:
The sample code in this section uses the notification function. This sample illustrates how you could write a reactor to add behavior to the WBLOCK command to tell it to include all text styles in the new drawing, instead of only the text styles that are referenced by the entities. It thus shows how to use wblock with nonentities. beginDeepCloneXlation() AcDbIdMapping has a function, , which returns the context in which the deep clone function was called. The contexts are the following: deepCloneContext()
The function is called when a call to is made. AcEditorReactor::abortDeepClone()AcDbDatabase::abortDeepClone() The following code uses a transient editor reactor derived from and overrides the function for the reactor. AcEditorReactorbeginDeepCloneXlation() // Since AcDbDatabase::wblock() only supports AcDbEntities // in its array of IDs, this code demonstrates how to add // additional objects during beginDeepCloneXlation(). If // it is a WBLOCK command, it asks the user if all text // styles should be wblocked. Otherwise, only those text // styles referenced by entities being wblocked // will be included (wblock's default behavior). // AsdkEdReactor is derived from AcEditorReactor. // void AsdkEdReactor::beginDeepCloneXlation(AcDbIdMapping& idMap, Acad::ErrorStatus* es) { if (idMap.deepCloneContext() == AcDb::kDcWblock && getYorN("Wblock all Text Styles")) { AcDbDatabase *pOrigDb, *pDestDb; if (idMap.origDb(pOrigDb) != Acad::eOk) return; *es = idMap.destDb(pDestDb); if (*es != Acad::eOk) return; AcDbTextStyleTable *pTsTable; *es = pOrigDb->getSymbolTable(pTsTable, AcDb::kForRead); if (*es != Acad::eOk) return; AcDbTextStyleTableIterator *pTsIter; *es = pTsTable->newIterator(pTsIter); if (*es != Acad::eOk) { pTsTable->close(); return; } AcDbTextStyleTableRecord *pTsRecord; AcDbObject *pClonedObj; for (; !pTsIter->done(); pTsIter->step()) { *es = pTsIter->getRecord(pTsRecord, AcDb::kForRead); if (*es != Acad::eOk) { delete pTsIter; pTsTable->close(); return; } // It is not necessary to check for already cloned // records. If the text style is already // cloned, wblockClone() will return Acad::eOk // and pCloneObj will be NULL. // pClonedObj = NULL; *es = pTsRecord->wblockClone(pDestDb, pClonedObj, idMap, Adesk::kFalse); if (*es != Acad::eOk) { pTsRecord->close(); delete pTsIter; pTsTable->close(); return; } *es = pTsRecord->close(); if (*es != Acad::eOk) { delete pTsIter; pTsTable->close(); return; } if (pClonedObj != NULL) { *es = pClonedObj->close(); if (*es != Acad::eOk) { delete pTsIter; pTsTable->close(); return; } } } delete pTsIter; *es = pTsTable->close(); } } |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:03
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.