我在模型空间里选择了一些实体,然后在组成块参照,为什么我的块参照里什么都没有,只有名字,不见图形,在cad上操做的时候可以选择它并插入,不过插入到模型空间什么都没有。我确定实体不是空的,块表也打开正常,record和块表也都关闭了的
- AcDbBlockTable *pBlkTable;
- if (acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlkTable, AcDb::OpenMode::kForWrite) != ErrorStatus::eOk)
- return;
- AcDbBlockTableRecord *record1 = new AcDbBlockTableRecord();
- AcDbObjectId recId;
- record1->setName(L"sssL");
- pBlkTable->add(recId, record1);
- AcDbObjectIdArray idArr;
- AcDbObjectIdArray mirIdArr;
- if (CSelectUtil::PromptSelectEnts(L"\n请选择要镜像的实体集\n", NULL, idArr)) {
- for (int i = 0; i < idArr.length(); i++)
- {
- AcDbEntity* pEnt = NULL;
- ErrorStatus es = acdbOpenObject(pEnt, idArr, AcDb::kForWrite);
- if (es == ErrorStatus::eOk&&pEnt != NULL)
- {
- AcDbEntity * pCopyEnt = NULL;
- pCopyEnt = AcDbEntity::cast(pEnt->clone());
- if (record1->appendAcDbEntity(pCopyEnt) == ErrorStatus::eOk) {
- AfxMessageBox(TEXT("InsertOK!"));
- }
- else {
- AfxMessageBox(TEXT("InsertFail!"));
- }
- pEnt->close();
- }
- }
- record1->close();
- pBlkTable->close();
- }
- bool CSelectUtil::PromptSelectEnts(const TCHAR * prompt, resbuf * rb,
- AcDbObjectIdArray & entIds)
- {
- ads_name selName;
- acutPrintf(prompt);
- int rc = acedSSGet(NULL, NULL, NULL, rb, selName);
- if (rc == RTNORM) {
- int length;
- acedSSLength(selName, &length);
- for (int i = 0; i < length; i++)
- {
- ads_name name;
- acedSSName(selName, i, name);
- AcDbObjectId oId;
- if (acdbGetObjectId(oId, name) == ErrorStatus::eOk) {
- entIds.append(oId);
- }
- }
- acedSSFree(selName);
- return true;
- }
- else {
- acedSSFree(selName);
- return false;
- }
- }
复制代码
|