- 积分
- 1980
- 明经币
- 个
- 注册时间
- 2009-4-4
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2016-6-6 12:33:02
|
显示全部楼层
本帖最后由 czx1234567 于 2016-6-6 12:38 编辑
还可以简化
void CAddToDwg::HighlightEntityInBlock(ads_point pickpoint, bool bHighlight)
{
ads_name ename;
ads_matrix adsmat;
struct resbuf *insStack;
acedNEntSelP(NULL, ename, pickpoint, TRUE, adsmat, &insStack);
AcDbObjectId selId;
acdbGetObjectId(selId, ename);
//ads_name sset;
//acedSSGet(NULL, pickpoint, NULL, NULL, sset);
//acedSSName(sset, 0, ename);
//AcDbObjectId blRefId;
//acdbGetObjectId(blRefId, ename);
int count = 0;
struct resbuf *rbIter = insStack;
AcDbObjectId *idArray = new AcDbObjectId[100];
AcDbObjectId objectId;
while (rbIter != NULL && count <100)
{
ename[0] = rbIter->resval.rlname[0];
ename[1] = rbIter->resval.rlname[1];
acdbGetObjectId(objectId, ename);
idArray[count] = objectId;
rbIter = rbIter->rbnext;
count++;
}
acutRelRb(insStack);
AcDbFullSubentPath subPath;
for (int i = count; i > 0; i--)
{
subPath.objectIds().append(idArray[i-1]);
}
AcDbEntity *pEntSel = NULL;
acdbOpenAcDbEntity(pEntSel, selId, AcDb::kForRead);
if (pEntSel ->isKindOf(AcDbAttribute::desc()))
subPath.objectIds().append(pEntSel ->ownerId());
pEntSel ->close();
subPath.objectIds().append(selId);
AcDbEntity *pEnt = NULL;
acdbOpenAcDbEntity(pEnt, subPath.objectIds().first(), AcDb::kForRead);
//AcDbBlockReference *pBlock = AcDbBlockReference::cast(pEnt);
if (bHighlight)
pEnt->highlight(subPath);
else
pEnt->unhighlight(subPath);
pEnt->close();
} |
|