|
static void TESTgrpcmd()
{
CString strGrp;
if(acedGetString(0,_T("\n输入组名"),strGrp.GetBuffer(10)) != RTNORM)
{
return;
}
strGrp.ReleaseBuffer();
ads_name ss;
if(acedSSGet(NULL,NULL,NULL,NULL,ss) != RTNORM)
{
return;
}
CString strLayer;
if(acedGetString(0,_T("\n输入层名称"),strLayer.GetBuffer(10)) != RTNORM)
{
acedSSFree(ss);
return;
}
创建组,改变层
AcDbGroup* pGrp = new AcDbGroup(strGrp);
long len ;
acedSSLength(ss,&len);
AcDbObjectId idObj;
ads_name enName;
AcDbEntity* pEnt;
ErrorStatus es;
for(int i = 0;i < len;i ++)
{
if(acedSSName(ss,i,enName) != RTNORM)
{
continue;
}
acdbGetObjectId(idObj,enName);
pGrp->append(idObj);
}
pGrp->setLayer(strLayer);
把组添加到词典中
AcDbDictionary* pGrpDic;
acdbHostApplicationServices()->workingDatabase()->getGroupDictionary(pGrpDic,AcDb::kForWrite);
AcDbObjectId idGrp;
pGrpDic->setAt(strGrp,pGrp,idGrp);
释放内存
pGrp->close();
pGrpDic->close();
acedSSFree(ss);
} |
|