|
/*
函数名称: DrawMcLine
功能描述: 删除实体
返回类型: 无
参数意义: 无
修改记录: */
bool McAcad::eraseEntity(int soft)
{
try
{
struct resbuf * pRb = NULL;
long nLen = 0;
ads_name Names;
ads_name entName;
ads_name strNames;//图元名称
AcDbObjectId RetId = AcDbObjectId::kNull;
CStringArray LayerArray;
LayerArray.Add(_T("McRect"));
int LayerArraySize = LayerArray.GetSize();
CString layerName;
AcDbEntity *pEnt = NULL;
for (int j=0;j<LayerArraySize;j++)
{
int count = LayerArray.GetSize();
layerName = LayerArray.GetAt(j);
pRb = acutBuildList(8, layerName,RTNONE);
if (pRb != NULL)
{
acedSSGet(_T("A"), NULL, NULL, pRb, Names);
acedSSLength(Names,&nLen);
for(int i=0;i<nLen;i++)
{
acedSSName(Names,i,entName);
if(Acad::eOk==acdbGetObjectId(RetId,entName))
{
acdbGetAdsName(strNames,RetId);
if(Acad::eOk==acdbOpenObject(pEnt,RetId, AcDb::kForWrite))
{
//删除实体
if(Acad::eOk != pEnt->erase(true))
{
acutPrintf(_T("\n删除失败!\n"));
}
}
pEnt->close();
}
acedSSFree(entName);
acdbNameClear(entName);
}
acedSSFree(Names);
acdbNameClear(Names);
acutRelRb(pRb);
}
}
LayerArray.RemoveAll();
return true;
}
catch(...)
{
edwrite("McAcad::eraseEntity() error");
return false;
}
return true;
} |
|