ARX 创建组实例(新建组,选择实体添加到组,输入层,修改组所在的层)
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);
}
页:
[1]