选择指定图层上的所有实体
Acad::ErrorStatus selectEntityInLayer(const std::wstring sLayerName, AcDbObjectIdArray& nIDs)
{
Acad::ErrorStatus es = Acad::eOk;
ads_name ents;
struct resbuf *rb;
rb = acutNewRb(AcDb::kDxfLayerName);
rb->restype = 8;
rb->resval.rstring = (ACHAR *)sLayerName.c_str();
rb->rbnext = NULL;
acedSSGet(L"X", NULL, NULL, rb, ents);
Adesk::Int32 entNums = 0;
acedSSLength(ents, &entNums);
if (entNums == 0)
es = Acad::eInvalidInput;
else
{
for (long a = 0; a < entNums; a++)
{
AcDbObjectId objId;
ads_name ent;
acedSSName(ents, a, ent);
acdbGetObjectId(objId, ent);
nIDs.append(objId);
}
}
acedSSFree(ents);
acutRelRb(rb);
return es;
}
设置当前层
Acad::ErrorStatus SetCurLayer(const std::wstring lpLayerName, AcDbDatabase* pDb/* = NULL */)
{
AcDbDatabase* pCurDb = pDb;
if (pCurDb == NULL)
{
pCurDb = acdbHostApplicationServices()->workingDatabase();
}
AcDbLayerTableRecordPointer spRecord(lpLayerName.c_str(), pCurDb, AcDb::kForRead);
Acad::ErrorStatus es = spRecord.openStatus();
if (es == Acad::eOk)
{
es = pCurDb->setClayer(spRecord->objectId());
}
return es;
}