[每日一码] ADSFUNCTION VPLAYEROFF
A/Vlisp 中队Viewport的图层冻结解冻比较麻烦,ARX很简单(vplyroff (car (entsel)) 0 "1" "2") 或者 (vplyroff (car (entsel)) 0 '("1" "2"))
0 - 冻结 ,1 - 解冻 ,2 - 全部解冻static int ads采用VPLyrOff(void)
{
struct resbuf *args=acedGetArgs();
if (args==NULL || args->restype!=RTENAME)
{
return RTNIL;
}
ads采用name vpEnt;
ads采用name采用set(args->resval.rlname,vpEnt);
AcDbObjectId id;
acdbGetObjectId(id,vpEnt);
AcDbEntity* pEnt=NULL;
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForWrite)!=Acad::eOk)
{
pEnt->close();
return RTNIL;
}
if (!pEnt->isKindOf(AcDbViewport::desc()))
{
pEnt->close();
return RTNIL;
}
AcDbViewport* pViewport=NULL;
pViewport=AcDbViewport::cast(pEnt);
if (pViewport==NULL)
{
pViewport->close();
pEnt->close();
return RTNORM;
}
args=args->rbnext;
if (args->restype!=RTSHORT && (args->resval.rint!=0 || args->resval.rint!=1 || args->resval.rint!=2))
{
pViewport->close();
pEnt->close();
return RTNIL;
}
int vInt=args->resval.rint;
args=args->rbnext;
AcDbObjectIdArray lyrIds;
if (vInt<2)
{
if (args!=NULL || args->restype!=RTSTR)
{
pViewport->close();
pEnt->close();
return RTNIL;
}
AcDbDatabase* pDb=acdbHostApplicationServices()->workingDatabase();
for (;args!=NULL;args=args->rbnext)
{
if (args->restype==RTSTR)
{
ACHAR* name=args->resval.rstring;
AcDbLayerTableRecordPointer lyrId(name,pDb,AcDb::kForRead);
if (lyrId.openStatus()==Acad::eOk)
{
lyrIds.append(lyrId->objectId());
}
}
}
if (lyrIds.isEmpty())
{
pViewport->close();
pEnt->close();
return RTNORM;
}
}
switch(vInt)
{
case 0:
{
if (pViewport->freezeLayersInViewport(lyrIds)==Acad::eOk)
{
pViewport->close();
pEnt->close();
return acedRetT();
}
break;
}
case 1:
{
if (pViewport->thawLayersInViewport(lyrIds)==Acad::eOk)
{
pViewport->close();
pEnt->close();
return acedRetT();
}
break;
}
default:
{
if (pViewport->thawAllLayersInViewport()==Acad::eOk)
{
pViewport->close();
pEnt->close();
return acedRetT();
}
break;
}
}
pViewport->close();
pEnt->close();
return RTNORM;
}
页:
[1]