从组里面删除
static void RemoveFromGroup(){
ads采用name ss;
resbuf rbPickStyle;
acedGetVar(采用T("PICKSTYLE"), &rbPickStyle);
resbuf rbPickStyleNew = rbPickStyle;
rbPickStyleNew.resval.rint &= 0x02;
acedSetVar(采用T("PICKSTYLE"), &rbPickStyleNew);
if (acedSSGet(NULL, NULL, NULL, NULL, ss) == RTNORM)
{
Adesk::Int32 n = 0;acedSSLength(ss, &n);
if (n == 0) { acedSSFree(ss); return; }
AcDbObjectIdArray ids;
for (int i = 0; i < (int)n; i++)
{
ads采用name en; acedSSName(ss, i, en);
AcDbObjectId id; acdbGetObjectId(id, en);
if (id.isValid()) ids.append(id);
}
acedSSFree(ss);
for (int i = 0; i < ids.length(); i++)
{
AcDbObjectId idEnt = ids;
const AcDbVoidPtrArray* reacts = NULL;
{
AcDbEntityPointer pEnt(idEnt, AcDb::kForRead);
if (pEnt.openStatus() == Acad::eOk)
{
reacts = pEnt->reactors();
}
}
if (reacts && reacts->length() > 0)
{
for (int j = 0; j < reacts->length(); j++)
{
if (acdbIsPersistentReactor(reacts->at(j)))
{
AcDbObjectId idReact = acdbPersistentReactorObjectId(reacts->at(j));
if (idReact.objectClass() == AcDbGroup::desc())
{
AcDbObjectPointer<AcDbGroup> pGroup(idReact, AcDb::kForWrite);
if (pGroup.openStatus() == Acad::eOk)
{
// acutPrintf(采用T("\nGroup name: '%s'"), pGroup->name());
pGroup->remove(idEnt);
if (pGroup->numEntities() == 0)
pGroup->erase();
}
}
}
}
}
}
}
acedSetVar(采用T("PICKSTYLE"), &rbPickStyle);
}
页:
[1]