[每日一码] ARX实例代码--使用acedSSGet()如何排除锁定层的实体?
void ssNoLock(ads采用name & tss){
AcDbObjectId objId=AcDbObjectId::kNull;
AcDbEntity *pEnt=NULL;
AcDbObjectId layerId=AcDbObjectId::kNull ;
AcDbLayerTableRecord*pLtblr=NULL;
ads采用name eName;
long i=0;
if ( RTNORM == acedSSLength(tss,&i))
{
/* go through the selection set to get layerid and
delete the entities on the locked layer from selectionset*/
for(long j=i-1;j >= 0;)
{
if (RTNORM == acedSSName(tss,j--,eName))
{
if (Acad::eOk == acdbGetObjectId (objId ,eName))
{
if (Acad::eOk ==acdbOpenAcDbEntity(pEnt,objId, AcDb::kForNotify,Adesk::kFalse))
{
layerId = pEnt->layerId();
if (Acad::eOk ==acdbOpenObject(pLtblr,layerId,AcDb::kForRead,Adesk::kFalse))
{
if ( pLtblr->isLocked())
{
//delete lockedentity from selection set
if(RTNORM !=acedSSDel(eName,tss))
acutPrintf(L"\nFailed to delete entity from selection set");
//close layerblock table
if (Acad::eOk !=pLtblr->close())
acutPrintf(L"\nFailed to close layer table record");
}
}
else
acutPrintf(L"\nFailed toopen layer table record");
//close entity
if (Acad::eOk != pEnt->close())
acutPrintf(L"\nFailed toclose entity");
}
else
acutPrintf(L"\nFailed to openentity");
}
else
acutPrintf(L"\nFailed to open object");
}
} //for loop
}
页:
[1]