|
How can I prevent the user from selecting "ALL" when using acedSSGet() using ObjectARX?
如何防止用户在使用 ObjectARX 使用 acedSSGet() 时选择"ALL"?[code]// this function allows the user to
// type "all", but only the entities
// in the current space are selected
void asdkSelectALL()
{
ads_name ss;
// get the selectionset
int res = acedSSGet (NULL, NULL, NULL, NULL, ss);
// if ok
if (res == RTNORM)
{
// get the length of the selection set
long length = 0l;
acedSSLength (ss, &length);
// see what we have
acutPrintf(L"\nBefore ss length = %ld", length);
// now loop round and find out which ones are in Paper space
for (long i=0l; i<length; ++i)
{
ads_name ename;
// extract the ename
if (acedSSName (ss, i, ename) != RTNORM)
continue;
AcDbObjectId objId;
// convert the ename to an object id
acdbGetObjectId (objId, ename);
// open the entity for read
AcDbObjectPointer<AcDbEntity>ent (objId, AcDb::kForRead);
// if ok
if (ent.openStatus () == Acad::eOk)
{
// get the owner object for this entity
AcDbObjectId ownerId = ent->ownerId();
// get the current dwg database
AcDbDatabase *dwg =
acdbHostApplicationServices()->workingDatabase();
// if the entity owner id is not the
// same as the current space id
if (dwg->currentSpaceId() != ownerId &&
dwg->viewportTableId() != ownerId &&
dwg->paperSpaceVportId() != ownerId)
{
// remove the entity from the selection set
acedSSDel (ename, ss);
}
}
}
acedSSLength (ss, &length);
// see what we have
acutPrintf(L"\nAfter ss length = %ld", length);
// test code
acedCommand (RTSTR, "._SELECT", RTPICKS,
ss, RTSTR, "", RTNONE);
// free the selection set after use
acedSSFree (ss);
}
}[/code] |
|