有大佬帮忙看看这个函数吗,一直运行出现块克隆失败,错误代码82或者83,不知道问题出在哪里,请教一下
void insertframe(const ZTCHAR* blockName, const AcGePoint3d& insertPoint)
{
std::wstring BlockNameManage = blockName + (std::wstring)(_T(“_”)) + RSG(3);
// 获取当前文档和数据库
AcDbDatabase* pCurDb = acdbHostApplicationServices()->workingDatabase();
CString strBlockFilePath = GetBlockFilePath();//外部DWG文件路径
//acutPrintf(_T(“路径:%s\n”), strBlockFilePath);
std::unique_ptr<AcDbDatabase> pExternalDb = std::make_unique<AcDbDatabase> (Adesk::kFalse); // 创建外部DWG文件对象
Acad::ErrorStatus es = pExternalDb->readDwgFile(strBlockFilePath);
if (es != Acad::eOk) {
acutPrintf(_T(“无法打开外部DWG文件\n”));
return;
}
// 获取外部DWG文件的块表
AcDbBlockTable* pExternalBlockTable = nullptr;
es = pExternalDb->getBlockTable(pExternalBlockTable, AcDb::kForRead);
if (es != Acad::eOk) {
acutPrintf(_T(“无法访问外部DWG文件中的块表\n”));
return;
}
// 查找指定名称的块
//AcDbBlockTableRecord* pExternalBlockRecord = nullptr;
//es = pExternalBlockTable->getAt(blockName, pExternalBlockRecord, AcDb::kForRead);
AcDbObjectId pExternalBlockRecord;
es = pExternalBlockTable->getAt(blockName, pExternalBlockRecord);
if (es != Acad::eOk) {
acutPrintf(_T(“无法找到指定的块:%s\n”), blockName);
return;
}
AcDbObjectIdArray objectIds; // 存储外部图纸中要克隆的对象ID
objectIds.append(pExternalBlockRecord); // 将块记录的对象ID加入到数组中
AcDbIdMapping idMap; // 用于映射克隆对象的ID
pExternalBlockTable->close();
es = pCurDb->wblockCloneObjects(objectIds, pCurDb->blockTableId(), idMap, AcDb::kDrcMangleName);
if (es != Acad::eOk)
{
acutPrintf(_T(“块克隆失败,错误代码: %d\n”), es);
return;