马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
static void WblockIds() {
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;
}
|