resbuf* getResbuf(AcDbObjectIdArray ids)
{
resbuf *result = NULL, *temp1, *temp2;
ads_name ename;
int length = ids.length();
for (int i = 0; i < length; ++i) {
acdbGetAdsName(ename, ids);
temp2 = acutBuildList(RTENAME, ename, RTNONE);
if (result == NULL) {
result = temp2;
} else {
temp1->rbnext = temp2;
}
temp1 = temp2;
}
return result;
}
void getLines(AcDbObjectIdArray& ids)
{
// select all lines from model space
// (without any error checking)
AcDbBlockTable *pTable;
AcDbBlockTableRecord *pModelSpace;
AcDbBlockTableRecordIterator *pIter;
AcDbEntity* pEnt;
acdbHostApplicationServices()->workingDatabase()->
getBlockTable(pTable, AcDb::kForRead);
pTable->getAt(ACDB_MODEL_SPACE, pModelSpace, AcDb::kForRead);
pTable->close();
pModelSpace->newIterator(pIter);
pModelSpace->close();
for (; !pIter->done(); pIter->step()) {
pIter->getEntity(pEnt, AcDb::kForRead);
if (pEnt->isKindOf(AcDbLine::desc()))
ids.append(pEnt->objectId());
pEnt->close();
}
delete pIter;
}
void getCircles(AcDbObjectIdArray& ids)
{
// select all circles from model space
// (without any error checking)
AcDbBlockTable *pTable;
AcDbBlockTableRecord *pModelSpace;
AcDbBlockTableRecordIterator *pIter;
AcDbEntity* pEnt;
acdbHostApplicationServices()->workingDatabase()->
getBlockTable(pTable, AcDb::kForRead);
pTable->getAt(ACDB_MODEL_SPACE, pModelSpace, AcDb::kForRead);
pTable->close();
pModelSpace->newIterator(pIter);
pModelSpace->close();
for (; !pIter->done(); pIter->step()) {
pIter->getEntity(pEnt, AcDb::kForRead);
if (pEnt->isKindOf(AcDbCircle::desc()))
ids.append(pEnt->objectId());
pEnt->close();
}
delete pIter;
}
以上为ObjectARX示例的acedSSGet使用K模式的示例,
void MyCustomCommand()
{
// save the old callback function
resbuf* (*oldFunc) (const ACHAR*);
acedSSGetKwordCallbackPtr(&oldFunc);
// set own callback function
acedSSSetKwordCallbackPtr(ssCallback);
// let the user make a selection
ads_name ss;
// this is the keyword list
// to use local and global keywords:
ACHAR kwordlist[] = { _T("LInes CIRcles _ LInes CIRcles") };
if (RTNORM != acedSSGet(_T("_:K"), NULL, kwordlist, NULL, ss)) {
// cancel
} else {
acutPrintf(_T("\nDone."));
acedSSFree(ss);
}
// restore old callback function
acedSSSetKwordCallbackPtr(*oldFunc);
}
现在想知道,当选择时不输入关键词,而是正常选择图元后,如何获取选择集ss?若输入了关键词,如LInes,ssCallback中的
AcDbObjectIdArray objIds;
getLines(objIds);
// create resbuf containing single
// enames from object id array
result = getResbuf(objIds);
返回值result从哪里可以获取到?
正常情况下acedSSGet获取到选择集后,都是要对选择集进行处理的,请问选择集处理相关部分代码应该加在哪里?