为什么还是不行呢 void lcdlg::delSS(char* nLayerName,AcDbObjectIdArray& nIDs) { Acad::ErrorStatus es = Acad::eOk; ads_name ents; struct resbuf *rb; struct resbuf blc; AcDbEntity *pE; rb=acutNewRb(AcDb::kDxfLayerName); rb->restype=8; rb->resval.rstring=(char*)nLayerName; rb->rbnext=NULL; acedSSGet("X",NULL,NULL,rb,ents); // long entNums=0; long entNums; acedSSLength(ents,&entNums); if (entNums == 0) es = Acad::eInvalidInput; else { for (long a = 0; a < entNums ; a ++) { AcDbObjectId objId; ads_name ent; AcDbObject* obj; acedSSName(ents,a,ent); acdbGetObjectId(objId, ent); acdbOpenObject(pE,objId,AcDb::kForWrite,false); nIDs.append(objId); pE->setLayer("0"); pE->close; obj->close; nIDs.append(objId); } } acedSSFree(ents); blc.restype = RTSTR; blc.resval.rstring = "0"; acedSetVar("CLAYER",&blc);//设置当前图层为0层 AcDbLayerTable * pLayerTbl;//定义层表指针 acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTbl, AcDb::kForWrite); AcDbLayerTableRecord * pLayerTblRcd; //定义层表记录指针 if ( Acad::eOk == pLayerTbl->getAt((char*)nLayerName, pLayerTblRcd , AcDb::kForWrite)) { pLayerTblRcd->erase(true);//删除图层 } pLayerTblRcd->close(); pLayerTbl->close(); acutRelRb(rb); } |