[每日一码] ObjextARX 删除图层实体(使用ADSRx全局函数)
/*函数名称: 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;
}
页:
[1]