|
static void RivilisWblockIds() {
resbuf *rb = acutNewRb(RTSTR);
if (acedGetFileD(L"Export file", nullptr, L"dwg", 32, rb) != RTNORM)
return;
AcString filename = rb->resval.rstring; acutRelRb(rb);
ads_name ss;
if (acedSSGet(nullptr, nullptr, nullptr, nullptr, ss) != RTNORM)
return;
Adesk::Int32 nSel = 0;
acedSSLength(ss, &nSel);
if (nSel == 0) { acedSSFree(ss); return; }
AcDbObjectIdArray ids; ids.setPhysicalLength(nSel);
for (int i = 0; i < nSel; i++) {
ads_name en; acedSSName(ss, i, en);
AcDbObjectId id;
if (acdbGetObjectId(id, en) == Acad::eOk) ids.append(id);
}
acedSSFree(ss);
Acad::ErrorStatus es;
AcDbDatabase *pOutputDb = new AcDbDatabase(false);
es = pOutputDb->readDwgFile(filename, AcDbDatabase::OpenMode::kTryForReadShare);
AcDbObjectId idModelSpace =
AcDbSymbolUtilities::servicesPtr()->blockModelSpaceId(pOutputDb);
AcDbIdMapping idMap;
es = acdbCurDwg()->wblockCloneObjects(ids, idModelSpace, idMap, AcDb::DuplicateRecordCloning::kDrcReplace);
pOutputDb->closeInput(true);
es = pOutputDb->saveAs(filename);
delete pOutputDb;
}
AcDbDatabase::wblock( AcDbDatabase* pOutputDb, const AcDbObjectIdArray& outObjIds, const AcGePoint3d& basePoint) have to be use with new created database: |
|